html - PHP Errors - Total of four -


this php code

<html> <head> <title>joerassic park</title> </head> <body> <?php $to = "joerassicpark.ddns@gmail.com"; $subject = "contact for"; $name = $_post["name"]; $email = $_post["email"]; $message = $_post["message"]; $headers = "from: $email"; $sent = mail('joerassicpark.ddns@gmail.com',$subject,$message,$headers); if($sent){ print('<a href="contact.html">thank you. click here return site.</a>'); } else { print "there issue contact form"; }  ?> </body> </html> 

and can see errors @ joerassicpark.ddns.net/contact.php

can tell me doing wrong?

the errors are:

notice: undefined index: name in c:\wamp\www\contact.php on line 9 notice: undefined index: email in c:\wamp\www\contact.php on line 10 notice: undefined index: message in c:\wamp\www\contact.php on line 11 warning: mail(): failed connect mailserver @ &quot;localhost&quot; port 25, verify &quot;smtp&quot; , &quot;smtp_port&quot; setting in php.ini or use ini_set() in c:\wamp\www\contact.php on line 13 

you assuming keys exist in post array.

this code should fix 3 of 4 errors.

<html> <head> <title>joerassic park</title> </head> <body> <?php  $error = false; $name = isset($_post["name"]) ? $_post["name"] : null; $email = isset($_post["email"]) ? $_post["email"] : null; $message = isset($_post["message"]) ? $_post["message"] : null;  if(is_null($name) || is_null($email) || is_null($message)) $error = true;  if(!$error) {     $to = "joerassicpark.ddns@gmail.com";     $subject = "contact for";     $headers = "from: $email";     $sent = mail('joerassicpark.ddns@gmail.com',$subject,$message,$headers); }  if(!$error && $sent){     print('<a href="contact.html">thank you. click here return site.</a>'); } else {     print "there issue contact form"; }  ?> </body> </html> 

however last error indicates not have mail server configured.

this has been answered in previous question here.


Comments

Popular posts from this blog

python - TypeError: start must be a integer -

c# - DevExpress RepositoryItemComboBox BackColor property ignored -

django - Creating multiple model instances in DRF3 -