I have a little problem with my if(isset($_POST[\'submit\']))
code. What I want is some echos and a table to not appear when the script is open but I do want it
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>
The $_post
function need the name value
like:
<input type="submit" value"Submit" name="example">
Call
$var = strip_tags($_POST['example']);
if (isset($var)){
// your code here
}
You must give a name to your submit button
<input type="submit" value"Submit" name="login">
Then you can call the button with $_POST['login']
Another option is to use
$_SERVER['REQUEST_METHOD'] == 'POST'
You never named your submit button, so as far as the form is concerned it's just an action.
Either:
<input type="submit" name="submit" ... />
)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
)
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" />