lexa Posted July 14, 2008 Share Posted July 14, 2008 Hi Every one, First of, I hope I'm posting in the right section of the forum, if not please forgive me My knowledge of phpp is poor/inexistant and thaks to some help I managed to create a script that send the info gathered throug a form in an email. That works fine. At the end of the script, if everything was all right, the info was sent to an email, and the script, using the echo function was saying something like, thanks for enquiring with us...blah blah blah. Now, for traffic monitoring purposes, instead of using a echo function, I wanted the script to open a new page (that would say the same.) I found out the open header function is the one I need. I then replace the last line of my code with the above mentionned function, and starting testing it... and surprose it worked... well, almost! Let me explain you what is wrong: the open header function does open a new page, but for some reason, the email is not sent anymore... Could you please help me with that guys? Please find below the whole script. The only thing I changed is the last line, replacing echo by open header. <?php // La variable $verif, va nous permettre d'analyser si la sémantique de l'email est bonne $verif="!^[a-zA-Z0-9._-]+@[a-zA-Z0-9._-]{2,}\.[a-zA-Z]{2,4}$!"; // On assigne et protége nos variables $email=$_POST["email"]; $from=htmlentities("From: ".$email); $message=stripslashes(htmlentities('surname: '.$_POST['surname'])); $message.="\n\n".'forename: '.$_POST['forename']."\n\n"; $message.="\n\n".'email address: '.$_POST['email']."\n\n"; $message.="\n\n".'Phone Number: '.$_POST['phone']."\n\n"; $message.="\n\n".'want to be on mailing list?: '.$_POST['info']."\n\n"; $message.="\n\n".'Where ?: '.$_POST['origin']."\n\n"; $message.="\n\n".$_POST["message"]."\n\n"; // On met ici notre email $destinataire="alex@sailnetuk.com"; /* On place le sujet du message qui ici sera toujours le même puisque dans la partie Html on l'a mis en caché grace au type="hidden" avec comme valeur "Vous avez un nouveau message" */ $objet='NEW NEILSON ENQUIRY - '.$_POST['what']; // C'est bon on est OK, vérifions si l'email est valide, grâce à notre sympathique REGEX if(!preg_match($verif,$email)) { echo "Your email address appears to be invalid, please check you entered it corectly."; } // On verifie si il y a un message elseif (trim($message)=="") { echo "Your message seems to be empty, please write a message, it will help us answering your enquiry"; } // Si tout est OK on envoie l'email else { mail($destinataire,$objet,$message,$from); Header('Location: enquiries.php'); } ?> the last line was before : echo "Your message has been succesfully sent! thank you for enquiring with us, we shall get back to you shortly" Could you pleae tell me what is wrong, as it does open a new page, but does not send the email any more... Many thanks in advance, and please forgive the funny sentences as, even though I am pretty fluent in english, it still is not my native language. Cheers guys, Lexa Quote Link to comment https://forums.phpfreaks.com/topic/114646-form-mail-and-open-header/ Share on other sites More sharing options...
DeanWhitehouse Posted July 14, 2008 Share Posted July 14, 2008 try using meta refresh Quote Link to comment https://forums.phpfreaks.com/topic/114646-form-mail-and-open-header/#findComment-589506 Share on other sites More sharing options...
lexa Posted July 14, 2008 Author Share Posted July 14, 2008 Cheers for getting back to me... But I have no idea what that means or how to implement it (my php skills are second to none... or none lol ) I'll search thought ot try to find out what you mean but a tiny bit more info would be much appreciated ! Cheers, Quote Link to comment https://forums.phpfreaks.com/topic/114646-form-mail-and-open-header/#findComment-589514 Share on other sites More sharing options...
DeanWhitehouse Posted July 14, 2008 Share Posted July 14, 2008 1st off, it's HTML not PHP and second try google, google is ure friend <meta content="REFRESH" > something like that Quote Link to comment https://forums.phpfreaks.com/topic/114646-form-mail-and-open-header/#findComment-589516 Share on other sites More sharing options...
lexa Posted July 14, 2008 Author Share Posted July 14, 2008 Yep, just did and found out it was html... What you actually suggest is that I put a meta refresh in the header of my script, so then, when they get the echoed message, they could be redirected (maybe after half a second or so) towards a url I could track. But I am not sure this would actually work as people are sent to the page mail.php (the page where the script quoted in the first post is), when the form is properly filled in, but also if there is a mistake (as in when they type in an invalid email address) This why I wanted an alternative to echo for the actual confirmation of successful inquiry... Did I get this right or where you suggesting using the refresh in another way? Quote Link to comment https://forums.phpfreaks.com/topic/114646-form-mail-and-open-header/#findComment-589528 Share on other sites More sharing options...
DeanWhitehouse Posted July 14, 2008 Share Posted July 14, 2008 replace the header with meta refresh , and it will work the same, but with a time delay Quote Link to comment https://forums.phpfreaks.com/topic/114646-form-mail-and-open-header/#findComment-589609 Share on other sites More sharing options...
lexa Posted July 14, 2008 Author Share Posted July 14, 2008 ok Blade, will try that. Thanks for your time! Quote Link to comment https://forums.phpfreaks.com/topic/114646-form-mail-and-open-header/#findComment-589615 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.