PDA

View Full Version : PHP forms - conformation page


vinnyvangogh
06-07-2015, 01:58 AM
I have PHP purchase/quote forms which use this to process the delivery via email.
This script just puts a a dark grey blank page with the link back to the form page.

How can I change it to open a link to a "message sent" - confirmation.html page.

/* PHP form validation: the script checks that the Email field contains a valid email address and the Subject field isn't empty. preg_match performs a regular expression match. It's a very powerful PHP function to validate form fields and other strings - see PHP manual for details. */
if (!preg_match("/\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*/", $email)) {
echo "<h4>Invalid email address</h4>";
echo "<a href='java_script:history.back(1);'>Back</a>";
}
elseif ( preg_match( "/[\r\n]/", $name ) || preg_match( "/[\r\n]/", $email ) ) {

echo "<h4>characters not allowed in this field</h4>";
echo "<a href='java_script:history.back(1);'>Back to e mail form</a>";

}

elseif ($email == "") {
echo "<h4>You must enter an e mail address</h4>";
echo "<a href='java_script:history.back(1);'>Back to e mail form</a>";
}
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {

} else {
echo "<h4>Can't send email</h4>";
}

?>

<p><a href="javascript:history.go(-1);">Return to Form Page</a></p>

Advice will be appreciated.

edbr
06-08-2015, 01:15 AM
/* Sends the mail and outputs the "Thank you" string if the mail is successfully sent, or the error string otherwise. */

elseif (mail($recipient,$email,$message, $from)) {

header("Location: http://mysite.com/thankyou.html");



} else {

vinnyvangogh
06-08-2015, 08:39 AM
Thanks for your help with this... really is much appreciated