English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

i want it to send my contact information, but it will always give me the wrong report even if i inserted the data correctly.

php code:
===========================








$name = $_POST[name];
$email = $_POST[email];
$comment = $_POST[comment];
$msg = "Name: $_POST[name]\n";
$msg.= "Email: $_POST[email]\n";
$msg.= "Phone: $_POST[phone]\n";
$msg.= "Comment/Message:\n";
$msg.= "$_POST[comment]\n

";
$msg.= "Message recieved: ".date('H:i, jS F');
If($name && $comment && $email){
@mail('truepal20032001@yahoo.com','Comment/Message',$msg,'FROM:'.$_POST[email]);
echo "Thankyou! You'll be replied soon.






";
echo '

';
}
else{
echo "ERROR!!"}
?>

2007-06-27 12:07:41 · 3 answers · asked by truepal20032001 2 in Computers & Internet Programming & Design

3 answers

Try this, it should work, I'm writing on the fly though so could be errors (sorry bout that in advanced :p)

//Notice the " into the POST
$name = $_POST["name"];
$email= $_POST["email"];
$comment= $_POST["comment"];

//There was no $_POST["phone"]; so here it is
$phone = $_POST["phone"];

/*VERY simple input check and validation and if all items have more than 1 character the mail the person */
if(strlen($name) > 1 && strlen($email) > 1 && strlen($comment) > 1 && strlen($comment) > 1)
{
$msg = "Name : $name
\n
Email : $email
\n
Phone: $phone
\n
Users Comment
\n
$comment";
//If mail fails for some reason
if(!mail('$email', 'Email Subject', '$msg'))
{
echo "Failed to send Email";
}
else
{
echo "

Thankyou! You'll be replied to shortly.

";
}
}
else
{
Your form for submiting goes here.
I suggeest you use $_GET when trying things out, it makes life ALOT easier, i.e no need to make forms or fake header.
}
?>
edit: forgot to add ";" at the end of echo "

.......

".

2007-06-27 13:05:34 · answer #1 · answered by Anonymous · 0 0

which line number does the pre processor think is the problem? what's the url to the page where the code exists? Seems like you're not testing nor initializing your variables well.

2007-06-27 12:39:31 · answer #2 · answered by D 3 · 0 0

the chances of you getting a decent answer to this are none
i just submitted a perl question
should show up soon

2007-06-27 12:13:32 · answer #3 · answered by Anonymous · 0 0

fedest.com, questions and answers