- Impact
- 3,135
Hi Folks,
I have just created a new contact.php form for use on one of our domain landers - see here: http://bucketboats.com
The form captures the data, and successfully sends this to the destination email, however, I can't seem to fix the 'error' message that appears once you click the 'send message' button?
Do i need to make a slight alteration to the script below?
<?php
$myemail = "[email protected]";
$yourname = check_input($_POST['name'], "Enter your name");
$email = check_input($_POST['email']);
$comments = check_input($_POST['offer'], "Offer Details");
$website = check_input($_POST['website']);
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}
$message = "Hello!
Your contact form has been submitted by:
Name: $yourname
E-mail: $email
Offer Details: $comments
End of message
";
mail($myemail, $ubject, $message);
header('Location: thanks.htm');
exit();
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
Any help would be appreciated.
Cheers,
Dan
I have just created a new contact.php form for use on one of our domain landers - see here: http://bucketboats.com
The form captures the data, and successfully sends this to the destination email, however, I can't seem to fix the 'error' message that appears once you click the 'send message' button?
Do i need to make a slight alteration to the script below?
<?php
$myemail = "[email protected]";
$yourname = check_input($_POST['name'], "Enter your name");
$email = check_input($_POST['email']);
$comments = check_input($_POST['offer'], "Offer Details");
$website = check_input($_POST['website']);
if (!preg_match("/([\w\-]+\@[\w\-]+\.[\w\-]+)/", $email))
{
show_error("E-mail address not valid");
}
if (!preg_match("/^(https?:\/\/+[\w\-]+\.[\w\-]+)/i", $website))
{
$website = '';
}
$message = "Hello!
Your contact form has been submitted by:
Name: $yourname
E-mail: $email
Offer Details: $comments
End of message
";
mail($myemail, $ubject, $message);
header('Location: thanks.htm');
exit();
function check_input($data, $problem='')
{
$data = trim($data);
$data = stripslashes($data);
$data = htmlspecialchars($data);
if ($problem && strlen($data) == 0)
{
show_error($problem);
}
return $data;
}
function show_error($myError)
{
?>
<html>
<body>
<b>Please correct the following error:</b><br />
<?php echo $myError; ?>
</body>
</html>
<?php
exit();
}
?>
Any help would be appreciated.
Cheers,
Dan
Last edited: