2010-01-21, 02:25 AM
I am using a PHP form on my site. It works perfectly, but when a user click Submit and there is an error, it just takes them to a white page with the error text that is entered in the PHP.
My question: Is there a way to make the form direct the user to an error page that I make?
Or
Is there a way to make a popup with the error text?
Here is the PHP code I am using:
Any help?
My question: Is there a way to make the form direct the user to an error page that I make?
Or
Is there a way to make a popup with the error text?
Here is the PHP code I am using:
<?php
##Simple & Secure PHP Contact Form ##
##By KuJoe @ www.AdminLounge.net##
session_start();
$to = "[email protected]";
$from = $_POST["email"];
$subject = $_POST["subject"];
$name = $_POST["name"];
$message = $_POST["message"];
$messagesent = "Name: $name \r\nMessage: $message \r\nSender's IP: $HTTP_SERVER_VARS[REMOTE_ADDR]";
$headers = "From: $from";
if (!preg_match("/^([a-zA-Z -])+$/",$name))
{
die('Name must consist of letters only.');
}
if (!preg_match("/^([0-9a-zA-Z\.\,\;\?\!\'\ \-])+$/",$subject))
{
die('Subject can only contain letters, numbers, and punctuation.');
}
if (!preg_match('/^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i',$from))
{
die('Invalid e-mail address.');
}
if (!preg_match("/^([0-9a-zA-Z\.\,\;\?\!\'\ \-])+$/",$message))
{
die('Message can only contain letters, numbers, and punctuation.');
}
mail($to,$subject,$messagesent,$headers);
header("Location: sent.html")
?>
Any help?