I have a form that requires all the fields to be filled in before it submits to an email. I want to remove this restriction. I'm hoping some one can tell me what to change. Any help is much appreciated. <?php $to = "name@email.com"; // if($_POST['send']) { $name = $_POST['name']; $email = $_POST['email']; $best = $_POST['best_time']; $number = $_POST['number']; $description = $_POST['description']; $best_number = $_POST['best']; $alt = $_POST['alt']; if(!$name || !$email || !$best || !$alt || !$description || !$best_number) { echo '<script type="text/javascript">alert("Please ensure all fields are complete");</script>'; echo "<meta http-equiv='refresh' content='0; url=contact.php'>"; }else{ $go++; } if(eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $go++; } else { echo '<script language="Javascript">alert ("Email is invlalid") </script>'; echo "<meta http-equiv='refresh' content='0; url=contact.php'>"; } $headers = "From: $name <$email>\n"; $headers .= "Reply-To: $name <$email>\n"; $date = date("d/m/y H:s"); if($go==2) { mail($to, "Submission on Handy Mensch", "New message has been posted from $name at $date \n\n Persons Name: $name \n Email: $email \n Best Time to contact: $best \n Best Phone Number: $best_number \n\n Alternate Number: $alt \n\n Description: \n $description", $headers); echo "<p style='text-align:center;'>Thank you $name your message has been sent</p>"; } } ?> Code (markup):
just enter: <?php $to = "name@email.com"; // if($_POST['send']) { $name = $_POST['name']; $email = $_POST['email']; $best = $_POST['best_time']; $number = $_POST['number']; $description = $_POST['description']; $best_number = $_POST['best']; $alt = $_POST['alt']; $headers = "From: $name <$email>\n"; $headers .= "Reply-To: $name <$email>\n"; $date = date("d/m/y H:s"); mail($to, "Submission on Handy Mensch", "New message has been posted from $name at $date \n\n Persons Name: $name \n Email: $email \n Best Time to contact: $best \n Best Phone Number: $best_number \n\n Alternate Number: $alt \n\n Description: \n $description", $headers); echo "<p style='text-align:center;'>Thank you $name your message has been sent</p>"; } ?> PHP:
Thanks but this code doesn't send out an email. After I hit submit I never receive the form data. Any advice? thx,
Hello, the same script is working on my end. Have you checked whether controller is going within if block or not? Regards,