Correct PHP contact form syntax? -


i trying follow php contact form tutorial here! seems pretty simple , i'm new php. however, when running project, many "notice" messages , errors!

i managed fix many of them, surrounding variables in issets

if(isset($_post['name'])){ $name = $_post['name'];} if(isset($_post['email'])){$email = $_post['email'];} if(isset($_post['phone'])){$phone = $_post['phone'];} if(isset($_post['message'])){$message = $_post['message'];} if(isset($_post['human'])){$human = intval($_post['human']);} if(isset($_post['from'])){$from = 'página web';} if(isset($_post['to'])){$to = 'bla@bla.com';} if(isset($_post['name'])){$subject = 'mensaje de página web';} if(isset($_post['name'])){$body = "de: $name\n teléfono: $phone\n e-mail:   $email\n mensaje:\n $message";} 

however, still these pesky notifications:

screenshot

line 16 is:

if ($_post["submit"]) { 

and rest example found in lines this:

<div class="col-sm-10">         <textarea class="form-control" rows="4" name="message"><?php echo htmlspecialchars($_post['message']);?></textarea>         <?php echo "<p class='text-danger'>$errmessage</p>";?> </div> 

even though these variables declared on top.

how can fix top notice , "undeclared variable" errors? i've tried looking other tutorials, seem same, ignoring issets (and making netbeans upset , full of warnings!) , using same syntax.

help appreciated.

the first time load form, $_post not have populated. try changing

if ($_post["submit"]) { 

to

if (isset($_post["submit"])) { 

to determine if form in fact submitted , continue accordingly.


Comments

Popular posts from this blog

c# - Validate object ID from GET to POST -

node.js - Custom Model Validator SailsJS -

php - Find a regex to take part of Email -