ts01
03-12-2006, 02:50 AM
Hi there,
I have the following scrippt for emailing a form which seems to work great, except when a user tries to put a return in the comments field. When they ttry and create a new line and try to send the form in pops up with an invalid input error on a seperate page.
I don't have much knowledge in php and found this script in another thread, invalid input is in the script but i don't know what it means and why it pops up on puting a new line in the comments.
Code>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?
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="site@domain.co.uk";
$message="Name: $name\n\nMessage: $comments\n\nE-mail Addres: $email";
if(mail($to,"Comments From Portfolio Website",$message,"From: $email\n")) {
header("Location: thankyou.htm");
} else {
header("Location: Error.htm");
}
?>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..
Incidently even if it does come up with an error, can you see why it doesnt redirect to the error.htm?
Any help on both issues would be great,
Thanks
Trev
I have the following scrippt for emailing a form which seems to work great, except when a user tries to put a return in the comments field. When they ttry and create a new line and try to send the form in pops up with an invalid input error on a seperate page.
I don't have much knowledge in php and found this script in another thread, invalid input is in the script but i don't know what it means and why it pops up on puting a new line in the comments.
Code>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>
<?
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="site@domain.co.uk";
$message="Name: $name\n\nMessage: $comments\n\nE-mail Addres: $email";
if(mail($to,"Comments From Portfolio Website",$message,"From: $email\n")) {
header("Location: thankyou.htm");
} else {
header("Location: Error.htm");
}
?>
>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>>..
Incidently even if it does come up with an error, can you see why it doesnt redirect to the error.htm?
Any help on both issues would be great,
Thanks
Trev