'Hi, I am making a contact form thingy, and my php isn't working any reason why?

Error: enter image description here

the code:

<?php 

    $name = $_POST['name'];
    $mail = $_POST['mail'];
    $message = $_POST['message'];

    $to ="[email protected]";
    $subject = "New contact from " .$name;
    $body = "";
    
    $body .= "Name : " .$name. "\r\n";
    $body .= "Email : " .$mail. "\r\n";
    $body .= $message. "\r\n";
    
    if($mail !=NULL){
    mail($to, $subject, $body);
    header("Location: index.html")  ;
    header("Location: done.html")  ;
}

?>

It's not sending the mail nor the page is working i need help ,thanks in advance :D



Solution 1:[1]

First, check if your servers are running properly. Then, for the following

$name = $_POST['name'];
$mail = $_POST['mail'];
$message = $_POST['message'];

There need to be values for each you. If you are getting the values from a form, then you have to handle the form first using the 'isset' function, to be able to pass the values to each variables.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 balogun semeton