jmr168 Posted February 13, 2008 Share Posted February 13, 2008 I've used the mail function successfully before, but I'm now creating a page with two forms that have two different submit buttons going to two different places to be processed. One form's action takes it to aweber and it works correctly with or without the other form in place. The one that goes to the code I wrote (process.php) goes through the script with no errors and makes it to the redirect at the end of the script without issues...except that the mail wasn't ever sent. I've double and triple checked for a missing " or something and I don't get what could be causing it. When I remove the form that submits to aweber, the mail function works. When I put both forms on the same page, they don't work. Here's what I got so far... <center> <form method="post" action="http://www.example.com/process.php"> <table> <tr><td colspan=2><center></center></td></tr> <tr><td>Name:</td><td><input type="text" name="name2" value="" size="20"></td></tr> <tr><td>Phone:</td><td><input type="text" name="phone" value="" size="20"></td></tr> <tr><td align="center" colspan="2"><input type="submit" name="submit" value="Submit"></td></tr> </table> </form> </center> </td> <td> <center> <form method="post" action="http://www.aweber.com/editedforsecurity" target="_new"> <input type="hidden" name="meta_split_id" value=""> <input type="hidden" name="unit" value="getwealthyeasy"> <input type="hidden" name="redirect" value="http://www.aweber.com/form/thankyou_vo.html"> <input type="hidden" name="meta_redirect_onlist" value=""> <input type="hidden" name="meta_adtracking" value=""> <input type="hidden" name="meta_message" value="1"> <input type="hidden" name="meta_required" value="from"> <input type="hidden" name="meta_forward_vars" value="0"> <table> <tr><td colspan=2><center></center></td></tr> <tr><td>Name:</td><td><input type="text" name="name" value="" size="20"></td></tr> <tr><td>Email:</td><td><input type="text" name="from" value="" size="20"></td></tr> <tr><td align="center" colspan="2"><input type="submit" name="submit" value="Submit"></td></tr> </table> </form> </center> Here is the process page that the first form should go to. I checked to be sure there are no conflicting variable names, and I changed the email address for posting the code here. I've double checked that my email is spelled and formatted correctly in the real script, but it still doesn't work. <?php $name = $_REQUEST['name2'] ; $email = $_REQUEST['email'] ; mail( "[email protected]", "PHONE CONTACT", " \n This person wants a call: \n Name: $name \n Phone: $phone \n " ); header('Location: http://www.example.com/phonesubmitted.php'); ?> Thanks in advance for any help, -John Link to comment https://forums.phpfreaks.com/topic/90994-php-mail-not-working-when-2-forms-are-on-the-same-page/ Share on other sites More sharing options...
jmr168 Posted February 14, 2008 Author Share Posted February 14, 2008 So I thought it might be due to both forms on the same page and I created an individual page for each form. I then used iframe to display each page inside their respective cells in the table where the forms were placed before. Same issue. Code is executed, but the mail does not show up at the address it is supposed to (though the exact same code works other sites I have with the same host). Did I miss something in the mail() function? What is wrong here? Link to comment https://forums.phpfreaks.com/topic/90994-php-mail-not-working-when-2-forms-are-on-the-same-page/#findComment-466451 Share on other sites More sharing options...
haku Posted February 14, 2008 Share Posted February 14, 2008 mail() is unreliable, as some hosts filter it as junk mail. So it could be the host you are using it on. To get around this problem, I personally use phpmailer (google it). Its a free class that you can use that allows you to send SMTP mails, which are not filtered by junk mail filters. Although now that I think of it, you should confirm that your mail is being sent. Try this: $mail_sent = mail( "[email protected]", "PHONE CONTACT", " \n This person wants a call: \n Name: $name \n Phone: $phone \n " ); if(!$mail) { echo "mail failed"; die; } And see if it goes through. If it dies, then you have an error in your mail function. If it goes through fine, then you have a bigger problem, and should try phpmailer or some other mail class. Link to comment https://forums.phpfreaks.com/topic/90994-php-mail-not-working-when-2-forms-are-on-the-same-page/#findComment-466492 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.