Re: Re - Direct a User after a completed Form
| From: | wesley grubbs:. | Date: | Mon, 01 Apr 2002 08:21:04 +0000 |
| Subject: | Re: Re - Direct a User after a completed Form | ||
| References: | 1 2 | Groups: | php.db |
| Request: | Send a blank email to php-db+get-18091@lists.php.net to get a copy of this message | ||
header is the appropriate one you're looking for:
header( "Location: thanks.php" );
what i do is use the page that processes all the data to also validate the
data. if the data does not pass through, it stays on this page with all the
errors listed in the body.
if it goes through.. then the 'header()' is loaded.
example.
page1
<form action="send-form.php" method=post>
all the stuff in your form.
i.e.
email:<br>
<input type="text" name="Email" size="30">
</form>
......................................................................
page2 (send-form.php)
<?php
$from = "$Email";
$from = "From: $from";
$headers = "$from\n";
$emailto ="your@email.com";
$exclude = array( "Submit_x", "Submit_y", "submit" );
$title ="custom title - $Title";
$message = "\n";
$message .= "-----------\n";
$message .= "This information was sent on ".date('dS of F Y (H:i)')."from
Netdiver.\n";
$message .= "-----------\n";
$message .= "Email: $Email\n";
function checkemail( $Email ) {
$regexp =
"/^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/";
if( !preg_match( $regexp, $Email ) )
return false;
return true;
}
$emailOK = checkemail( $Email );
if ($emailOK == true ){
// echo $message;
header( "Location: thanks.php" );
mail( $emailto, $title, $message, $headers );
exit( );
}
?>
<html>
<head>
<title>Error!! Form not filled properly.</title>
</head>
<body>
you need to enter a valid email address
</body>
</html>
..................................
page 3 (thanks.php)
<html>
<head>
<title>thanks</title>
</head>
<body>
Thanks!
</body>
</html>
.................................................................
hope this helps
wes