ssp911 Posted December 3, 2007 Share Posted December 3, 2007 Plz help with: How to get the "Thank_you_message.html" working in the return message of the FormHandlers php script: Thanks, Chris. <?php // information can also be placed in database $Name = $_POST['Name']; $Surename = $_POST['Surename']; $EmailAddress = $_POST['EmailAddress']; $Comments = $_POST['Comments']; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $EmailAddress . "\r\n"; $formsent = mail('email@','information coming from Form2.htm','Name: '.$Name.'<br>Surname: '.$Surename.'<br>Comments: '.$Comments,$headers); if($formsent){echo 'Thank you for your message.click <a href="Thank_you_message.html" >here</a> to continue';} else{echo "<p>Sorry, something went wrong with the form, please try again later.</p>";} ?> Link to comment https://forums.phpfreaks.com/topic/79919-formhandler/ Share on other sites More sharing options...
mmarif4u Posted December 3, 2007 Share Posted December 3, 2007 can u be more clear with ur q?. Link to comment https://forums.phpfreaks.com/topic/79919-formhandler/#findComment-404763 Share on other sites More sharing options...
paradigmapc Posted December 3, 2007 Share Posted December 3, 2007 I don't really know what you are asking but try using an absolute path to the thank you page in your anchor tag <a> such as: if the page is here http://www.yoursite.com/sub/Thank_you_message.html use /sub/Thank_you_message.html Link to comment https://forums.phpfreaks.com/topic/79919-formhandler/#findComment-404772 Share on other sites More sharing options...
Northern Flame Posted December 3, 2007 Share Posted December 3, 2007 I think I know what you mean, try this: <?php // information can also be placed in database $Name = $_POST['Name']; $Surename = $_POST['Surename']; $EmailAddress = $_POST['EmailAddress']; $Comments = $_POST['Comments']; $headers = 'MIME-Version: 1.0' . "\r\n"; $headers .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $headers .= 'From: ' . $EmailAddress . "\r\n"; $formsent = mail('email@','information coming from Form2.htm','Name: '.$Name.' Surname: '.$Surename.' Comments: '.$Comments,$headers); if($formsent){include 'Thank_you_message.html';} else{echo "<p>Sorry, something went wrong with the form, please try again later.</p>";} ?> Link to comment https://forums.phpfreaks.com/topic/79919-formhandler/#findComment-404780 Share on other sites More sharing options...
mmarif4u Posted December 3, 2007 Share Posted December 3, 2007 Also can try this: if($formsent){header ('location:Thank_you_message.html');} Link to comment https://forums.phpfreaks.com/topic/79919-formhandler/#findComment-404786 Share on other sites More sharing options...
mr_mind Posted December 3, 2007 Share Posted December 3, 2007 Here is how i would organize it an error check the code. I have fixed a whole bunch of coding mistakes that are all probably due to not organizing your code. the method of error checking i use is helpful because if an error is encountered the script stops and shows you the message. This should be the contents of mailform.php <?php function spamcheck($field) { //eregi() performs a case insensitive regular expression match if(eregi("to:",$field) || eregi("cc:",$field)) { return TRUE; } else { return FALSE; } } if($_POST['submit']) { //if the form is submitted make sure that all of the information is supplied if($_POST['name'] && $_POST['surname'] && $_POST['comment'] && $_POST['email']) { //if all of the information is supplied check if the email address is valid if (spamcheck($_POST['email'])==FALSE) { //if we make sure this is correct then we send the email $email = $_POST['email']; $subject = 'Subject: information coming from Form2.htm'; $message = $_POST['comment']; $name = $_POST['name']; $surname = $_POST['surname']; $headers = 'From: ' . $email; if(mail("[email protected]", $subject ,$message, $headers)) { //if we send the email then set the variable which contains the uccess message $message = 'Thank you for your comments. <a href=Thank_you_message.html>Click here</a> to continue.'; } else { //if we do not send the email set the error message that we failed $error = 'Failed sending email. Please notify the server admin.'; } } else{ //if the email is invalid we should tell the user $error = 'The email address supplied was invalid'; } } else { //if not all of the information is filled out then we should tell the user $error = 'You must fill out all of the information'; } } $title = 'Submit a comment'; ?> <html> <head> <title> <?php print $title; ?> </title> </head> <body> <?php if(!$_POST['submit']) { //if the form has not been submitted show the form print '<form method=post action=mailform.php>'; print 'Email:<br /><input name=email type=text /><br />'; print 'First Name:<br /><input name=name type=text /><br />'; print 'Last Name:<br /><input name=surname type=text /><br />'; print 'Message:<br /><textarea name=comment rows=15 cols=40></textarea><br />'; print '<input name=submit type=submit />' print '</form>'; } else { //if the form was submitted check to see if the script was successful or otherwize if(isset($message)) { //if everything is successful we print the message print $message; } else{ if(isset($error)) { //if we get an error along the way lets tell the user the error //we should also show them what they submitted in the form so that they can change it print $error; print '<form method=post action=mailform.php>'; print 'Email:<br /><input name=email type=text value=' . $_POST['email'] . ' /><br />'; print 'First Name:<br /><input name=name type=text value=' . $_POST['name'] . ' /><br />'; print 'Last Name:<br /><input name=surname type=text value=' . $_POST['surname'] . ' /><br />'; print 'Message:<br /><textarea name=comment rows=15 cols=40>' . $_POST['comment'] . '</textarea><br />'; print '<input name=submit type=submit />' print '</form>'; } } } ?> </body> </html> Link to comment https://forums.phpfreaks.com/topic/79919-formhandler/#findComment-404795 Share on other sites More sharing options...
ssp911 Posted December 3, 2007 Author Share Posted December 3, 2007 Hello all, Thanks for the good work. I need some time to figure it all out but the first two did not work. I'm still working on the newly written (good-looking) mailform.php and for that one I need more time to get it working. Thanks again so far, I'll let you all know when and if it works. Regards, Link to comment https://forums.phpfreaks.com/topic/79919-formhandler/#findComment-404884 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.