Using if(isset($_POST['submit'])) to not display echo when script is open is not working
You need to give your submit <input>
a name or it won't be available using $_POST['submit']
:
<p><input type="submit" value="Submit" name="submit" /></p>
What you're checking
if(isset($_POST['submit']))
but there's no variable name called "submit".
well i want you to understand why it doesn't works.
lets imagine if you give your submit button name delete
<input type="submit" value="Submit" name="delete" />
and check if(isset($_POST['delete']))
then it works in this code you didn't give any name to submit button and checking its exist or not with isset();
function so php didn't find any variable like "submit" so its not working now try this :
<input type="submit" name="submit" value="Submit" />
You never named your submit button, so as far as the form is concerned it's just an action.
Either:
- Name the submit button (
<input type="submit" name="submit" ... />
) - Test
if (!empty($_POST))
instead to detect when data has been posted.
Remember that keys in the $_POST
superglobal only appear for named input elements. So, unless the element has the name attribute, it won't come through to $_POST
(or $_GET
/$_REQUEST
)