Form error url?
Posted: Thu May 18, 2006 11:54 am
pickle | Please use
Thanks,
Des
pickle | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I am using the following PHP script to process a form. It all works fine, but if there are missing fields the user is sent to a blank error page (this is at the top of the script). How could I change it so that I can use my own error page (URL)?
Script:
[syntax="php"]
<?php
$errors=0;
$error="The following errors occured while processing your form input.<ul>";
if($Name=="" || $Age=="" || $Gender=="" || $Location=="" || $Interests=="" || $Bands=="" || $Gig=="" || $Discs=="" || $Books=="" || $Films=="" || $Email=="" || $Show=="" ){
$errors=1;
$error.="<li>You did not enter one or more of the required fields. Please go back and try again.";
}
if(!is_uploaded_file($Photo)){
$error.="<li>The file, ".$Photo_name.", was not uploaded!";
$errors=1;
}
if($errors==1) echo $error;
else{
$image_part = date("h_i_s")."_".$Photo_name;
$image_list[14] = $image_part;
copy($Photo, "files/".$image_part);
$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($PHP_SELF),"/"));
$message="Name: ".$Name."
Age: ".$Age."
Gender: ".$Gender."
Location: ".$Location."
Interests: ".$Interests."
Bands: ".$Bands."
Gig: ".$Gig."
Discs: ".$Discs."
Books: ".$Books."
Films: ".$Films."
Email: ".$Email."
Show: ".$Show."
Msn: ".$Msn."
Website: ".$Website."
Photo: ".$where_form_is."files/".$image_list[14]."
";
mail("me@somewhere.com","Form Submitted at your website",$message,"From: phpFormGenerator");
header("Refresh: 0;url=http://somewhere.com/info/forms/received.html ");
}
?>
Des
pickle | Please use[/syntax]
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]