Categories: MSDN / DotNet / Java / Scripts / Linux / PHP Ask - La ask - La Answer

need help with php comment sender

hi,

i am having problems with my php sender,

the code that i put in my webpage is

<form action="http://comments.krakingswood.co.uk/sent.php" method="post">
Your Name: <input type="text" name="name"><br>
Your E-mail (optional): <input type="text" name = "email"><br><br>
Comments<br>
<textarea name="comments"></textarea><br><br>
<input type="submit" value="Submit">
</form>

the coding in the php file is

<?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="abuse@krakingswood.co.uk";
$message="This is a new comment posted by $name. They posted it from the email address of: $email"\n $comments"\n;
if(mail($to,"Website Abuse",$message,"From: $email\n")) {
echo "Thank you for your help. We will try to sort out the problems as soon as possible.";
} else {
echo "There was a problem sending the mail. Please check that you filled in the form correctly.";
}
?>

and i get the following error message up when i am testing it

Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home/david/public_html/comments/sent.php on line 16

Parse error: parse error, unexpected T_STRING in /home/david/public_html/comments/sent.php on line 16

can you please help me on this??

thanks

dave
[1710 byte] By [davesd] at [2007-11-11 8:26:15]
# 1 Re: need help with php comment sender
Can u hightlight line 16 and the line above line 16 plz.
major at 2007-11-11 23:34:50 >
# 2 Re: need help with php comment sender
line 16 is

$message="This is a new comment posted by $name. They posted it from the email address of: $email"\n $comments"\n;
davesd at 2007-11-11 23:35:50 >
# 3 Re: need help with php comment sender
Change this:

$message="This is a new comment posted by $name. They posted it from the email address of: $email"\n $comments"\n;

into:


$message="This is a new comment posted by $name. They posted it from the email address of: $email <br> $comments";

Voila!!!
ablaye at 2007-11-11 23:36:49 >
# 4 Re: need help with php comment sender
thank you very much for you help

works perfectly now

dave
davesd at 2007-11-11 23:37:49 >