PHP $_POST spits out "Notice: Undefined index:" -
this question has answer here:
i've been playing around php post & seem never work properly. i've looked on trying understand why html elements cannot found through name tags no avail.
the common response add: if(isset($_post[...])) when included, form never goes through returns false.
<html> <body> <form action="" method="post"> <input type="text" placeholder="name here" name="name"> <input type="submit" name="submit" value="show name"> </form> </body> <?php if(isset($_post["submit"])){ echo $_post["name"]; }else echo "no name"; ?> </html>
is interpreter issue? have replicated other people's sample code in theirs works still faced same issues.
in php script, use $_post. because method specified in html form says post. if want use $_get change method attribute , not post.
alternatively can use $_request, although it's not security safe.
if else fails, place php script @ top before html
Comments
Post a Comment