PHP Errors – Total of four [closed]

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 to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() in C:\wamp\www\contact.php on line 13

You are assuming that those keys exist in the POST array.

This code should fix 3 of 4 errors.

<title>Joerassic Park</title>

$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 = "[email protected]";
    $subject = "Contact For";
    $headers = "From: $email";
    $sent = mail('[email protected]',$subject,$message,$headers);

if(!$error && $sent){
    print('<a href="">Thank you. Click here to return to site.</a>');
} else {
    print "There was an issue with your contact form";


However your last error indicates that you do not have a mail server configured.

This has been answered in a previous question here.

Browse More Popular Posts

Leave a Comment