Am new to PHP. Trying to send mail using php. Everything fine. Except success message displays in new page.
My php code is
<?php
$name=$_POST['name'];
$email=$_POST['email'];
$subject=$_POST['subject'];
$message=$_POST['message'];
$to='abc@xyz.com';
$headers = 'From: '.$name."\r\n" .
'Reply-To: '.$email."\r\n" .
'X-Mailer: PHP/' . phpversion();
$subject = $subject;
$body='You have got a new message from the contact form on your website .'."\n\n";
$body.='Name: '.$name."\n";
$body.='Email: '.$email."\n";
$body.='Subject: '.$subject."\n";
$body.='Message: '."\n".$message."\n";
if(mail($to, $subject, $body, $headers)) {
die('Message sent.');
} else {
die('Error: Mail failed');
}
?>
And this is my output.
Please help me to print this mesage below my contact form.