First of all am the beginner please help me out.
I have used the following code in php for sending a email directly from my page but it is not working.
//This page should not be accessed directly. Need to submit the form.
echo "error; you need to submit the form!";
$name = $_POST['name'];
$email = $_POST['email'];
$contact_no = $_POST['contact_no'];
echo "Name and email are mandatory!";
echo "Bad email value!";
$email_from ='email@example.com';//<== update the email address
$email_subject = "New Form submission";
$email_body = "You have received a new message from the user $name.\n".
"Here is the message:\n $contact_no".
$to = "firstname.lastname@example.org";//<== update the email address
$headers = "From: $email\r\n";
$headers .= "Reply-To: $email \r\n";
//Send the email!
//done. redirect to thank-you page.
// Function to validate against any email injection attempts
$injections = array('(\n+)',
$inject = join('|', $injections);
$inject = "/$inject/i";
The error is after submitting is:
error; you need to submit the form!
Warning: Cannot modify header information - headers already sent by (output started at D:\INETPUB\VHOSTS\stockshasthra.in\httpdocs\form-to-email.php:5) in D:\INETPUB\VHOSTS\stockshasthra.in\httpdocs\form-to-email.php on line 35
Thanks in advance