i want to add a newletter signup in my HTML page. which send the email to my ID about what user entered. Here is my php code <?php if(isset($_POST['email'])) { // EDIT THE 2 LINES BELOW AS REQUIRED $email_to = "venuskalra@gmail.com"; $email_subject = "email subject"; $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); function died($error) { // your error code can go here echo "We are very sorry, but there were error(s) found with the form your submitted. "; echo "These errors appear below.<br /><br />"; echo $error."<br /><br />"; echo "Please go back and fix these errors.<br /><br />"; die(); } // validation expected data exists if(!isset($_POST['email'])) { died('We are sorry, but there appears to be a problem with the form your submitted.'); } $email_from = $_POST['email']; // required $error_message = ""; $email_exp = "^[A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$"; if(!eregi($email_exp,$email_from)) { $error_message .= 'The Email Address you entered does not appear to be valid.<br />'; } if(strlen($error_message) > 0) { died($error_message); } $email_message = "Form details below.\n\n"; function clean_string($string) { $bad = array("content-type","bcc:","to:","cc:","href"); return str_replace($bad,"",$string); } \ $email_message .= "Email: ".clean_string($email_from)."\n"; // create email headers $headers = 'From: '.$email_from."\r\n". 'Reply-To: '.$email_from."\r\n" . 'X-Mailer: PHP/' . phpversion(); @mail($email_to, $email_subject, $email_message, $headers); ?> <!-- include your own success html here --> Thank you for submiting your testimonial. <? } ?> PHP: bUT unfortunately its not sending email.
It is working here , while i tested it. <form action="page4.php" method="post"> email<input type="text" name="email"><br> message<input type="text" name="message"><br> <input type="submit" name="save" value="save"> </form> Please check that if isset($_POST['email']) is true. means if this post variable has values in it after the form is posted to this page. If yes. Then there might be some issues with the email sender on the web server. may be email mail server is not sending outward email.
I think That should be $email_from = $_GET['email']; // required you could have used online form generator though , you do not have to suffer with 20 lines of code , Google free php form generator/maker