cgibie
01-06-2006, 09:31 PM
Hello I have this code, but it doesn't tell me any errors and echos any text, what's wrong with it?
<?php
function checkOK($field)
{
if (eregi("\r",$field) || eregi("\n",$field)){
die("Invalid Input!");
}
}
$name = $_POST['name'];
checkOK($name);
$email = $_POST['email'];
checkOK($email);
$comments=$_POST['comments'];
checkOK($comments);
$to = "dave555th@yahoo.com";
$message = "$name just contacted you. He said: \n $comments \n";
if ($mail($to, "Comments", $message, "From: $email\n")) {
echo "Thanks for your comments.";
}
else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>
<?php
function checkOK($field)
{
if (eregi("\r",$field) || eregi("\n",$field)){
die("Invalid Input!");
}
}
$name = $_POST['name'];
checkOK($name);
$email = $_POST['email'];
checkOK($email);
$comments=$_POST['comments'];
checkOK($comments);
$to = "dave555th@yahoo.com";
$message = "$name just contacted you. He said: \n $comments \n";
if ($mail($to, "Comments", $message, "From: $email\n")) {
echo "Thanks for your comments.";
}
else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>