I am building a website as an exercise. It has a 'contact us' page in which I have created a form. I have saved that page with .php extension, believing that in such case only, the webpage would send the form data to another php page. Once send button is pressed, it leads to a php page with html and php script which should send an email automatically. but that is not happening. here is the php script:
<?php
if(isset($_POST['submit']))
{
$name = $_POST['name'];
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$country = $_POST['country'];
$city = $_POST['city'];
$message = $_POST['contactusmessage'];
$headers = '[email protected]';
$to = '[email protected]';
$mail=mail($to,$message,$headers);
if($mail){
echo"<p>Thanks $name for the message.</p>";
echo"<p>We will reply to $email</p>";
}
else{
echo "Mail sending failed.";
}
}
?>
Please tell me where I am going wrong?