hi guys,
im creating this contact form code, apparently its having error as below

[Parse error: parse error, unexpected '"' in E:\wwwusr\vhosts\ceriategas-premium.com\httpdocs\test3\send_contact.php on line 6]

ive checked the line 6, but i cnt find the errors...

do help me please...

<?php
if (isset($_POST['submit'])) {
  // Collect variables
$subject="$name";
$message1="$coname";
$message=2"$phoneoff";
$message3="$mobile";
$header="from: $name <$mail_from>";
$mail_from="$email";
$message4="$comments";

//Enter your email add
$to ='@!#$l@!@#$.com';

$send_contact=mail($to,$message1,$message2,$message3,$header,$mail_from,$message4);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

I don't really know any PHP, but I guess the problem really is on line 6. It says $message=2"$phoneoff"; while it should say $message2="$phoneoff";. Am I right?

spot on guys.. .. ive fixed it ;-)
i shall upload this again, let see if me encounter anything else..

cheers again...

guys,...
after done with the upload..

im having the same parse error but at line 25...
im just wondering... now

help please...

Parse error: parse error, unexpected on line 25

please close that if loop at the last line u will get it.

this is the code actually. . i cnt seems to figure it out.. .
error at line 25..
thanks for the help

<?php
if (isset($_POST['submit'])) {
  // Collect variables
$subject="$name";
$message1="$coname";
$message2="$phoneoff";
$message3="$mobile";
$header="from: $name <$mail_from>";
$mail_from="$email";
$message4="$comments";

//Enter your email add
$to ='@!#$l@!@#$.com';

$send_contact=mail($to,$message1,$message2,$message3,$header,$mail_from,$message4);

// Check, if message sent to your email
// display message "We've recived your information"
if($send_contact){
echo "We've recived your contact information";
}
else {
echo "ERROR";
}
?>

put another } at bottom

sorry, ... is it like below?

echo "ERROR";
}}
?>

yes exactly.

thanks for the help, sorry im being a pain indeed...
is there any web based error checker for php available on www so i can check me self there ;-)

thanks praghna

No not other than uploading it and giving it a whirl and try to fix any errors PHP stated.

I noticed your mail() function looks rather odd.

What is the error you are currently getting?

the parse error is no more...apparently the screen seems to be totally blank now after hitting the "submit" button .... and im not receving no email at all ...

so what you suggest about the mail function?

Well the mail function expects their to be 4 paramaters you clearly have more.

<?php
$to = "me@mydomain.com";
$subject = "Welcome to mydomaiin";
$ip = $_SERVER['REMOTE_ADDR'];
$body = <<<EOD
<h!>Welcome to my domain</h1>
<p>Thankyou for signing up. We have documented you ip as: $ip</p>
EOD;
// Yes you can include PHP variables in that block of code.
$headers = "From: no-reply@mydomain.com \r\n";
$headers .= "Content-type: text/html \r\n";

// IMPORTANT BIT
// mail( TO , SUBJECT , BODY , ADDITIONAL_HEADERS )
if( mail( $to , $subject , $body , $headers ) ) {
echo "Message successfully sent";
} else {
echo '<span style="color: red;">Error sending message.</span>';
}
?>

This will send an email perfectly. Well it should do I have written it off of the top of my head so I can't be certain. But I have been writing these for years so this should be correct.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.