chairmanMeow Posted November 27, 2010 Share Posted November 27, 2010 Hi Having thought the PHP form was working OK, I took a break. Upon return, it's up to its old tricks. Could anyone glance over this code for blatant errors? It works when it wants and when it doesn't... Much appreciated <? $select=$_POST['select']; $name=$_POST['name']; $email=$_POST['email']; $confirmail=$_POST['confirmail']; $month=$_POST['month']; $day=$_POST['day']; $year=$_POST['year']; $leaving=$_POST['leaving']; $hour=$_POST['hour']; $minutes=$_POST['minutes']; $ampm=$_POST['ampm']; $going=$_POST['going']; $flightnumber=$_POST['flightnumber']; $pay=$_POST['pay']; $song=$_POST['song']; $comments=$_POST['comments']; $to="beepbeepyeah@kabeoke.com"; header('Location:http://www.kabeoke.com'); $message="Message Type: $select\n\nName: $name\n\nEmail: $email\n\n$confirmail\n\nDate of Journey: $month, $day, $year\n\nLeaving From: $leaving\n\nDeparture Time: $hour:$minutes $ampm\n\nGoing to: $going\n\nFlight Number: $flightnumber\n\nPayment Method: $pay\n\nSong Requests: $song\n\nComments: $comments"; if(mail($to,"Slap it - message from Kabeoke.com!",$message,"From: $email\n")) { } else { echo "There was a problem sending the mail. Please check that you filled in the form correctly."; } ?> Quote Link to comment Share on other sites More sharing options...
Rifts Posted November 27, 2010 Share Posted November 27, 2010 try <? $select=$_POST['select']; $name=$_POST['name']; $email=$_POST['email']; $confirmail=$_POST['confirmail']; $month=$_POST['month']; $day=$_POST['day']; $year=$_POST['year']; $leaving=$_POST['leaving']; $hour=$_POST['hour']; $minutes=$_POST['minutes']; $ampm=$_POST['ampm']; $going=$_POST['going']; $flightnumber=$_POST['flightnumber']; $pay=$_POST['pay']; $song=$_POST['song']; $comments=$_POST['comments']; $to="beepbeepyeah@kabeoke.com"; $message="Message Type: $select\n\nName: $name\n\nEmail: $email\n\n$confirmail\n\nDate of Journey: $month, $day, $year\n\nLeaving From: $leaving\n\nDeparture Time: $hour:$minutes $ampm\n\nGoing to: $going\n\nFlight Number: $flightnumber\n\nPayment Method: $pay\n\nSong Requests: $song\n\nComments: $comments"; if(mail($to,"Slap it - message from Kabeoke.com!",$message,"From: $email\n")) { header('Location:http://www.kabeoke.com'); } else { echo "There was a problem sending the mail. Please check that you filled in the form correctly."; } ?> Quote Link to comment Share on other sites More sharing options...
chairmanMeow Posted November 27, 2010 Author Share Posted November 27, 2010 Thanks Rifts It seems to work the same even with header after the mail bit. I'm beginning to think that this has something to do with an email address verifier at the server - it works with established email addresses entered, but not with random stuff. Anyways, thanks very much for your suggestion. Quote Link to comment Share on other sites More sharing options...
Pikachu2000 Posted November 27, 2010 Share Posted November 27, 2010 The From: header should contain an email address that is valid on the server, not the email address of the person submitting the form. That should go in a Reply-to: header if needed. The header() redirect shouldn't be called before the mail() function has completed, and it should actually be conditional upon the mail() function's success, and be followed immediately by an exit(); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.