Jump to content

Parse error: syntax error, unexpected $end in send.php


jamesclues

Recommended Posts

PHP Contact form Send Below. Line 54 where the error says is ?> at the end please can someone help me..

 

<?
if($_POST["send"]) {

   //collect post variables
   $name = $_POST["name"];
   $address = $_POST["address"];
   $town = $_POST["town"];
   $postocde = $_POST["postocde"];
   $telephone = $_POST["telephone"];
   $email = $_POST["email"];
   $enquiry = $_POST["enquiry"];


   //build email body
   $body .= "Name: $name \n";
   $body .= "Address: $address \n";
   $body .= "Town: $town \n";
   $body .= "Postcode: $postcode \n";
   $body .= "Telephone: $telephone \n";
   $body .= "Email: $email \n";
   $body .= "Enquiry: $enquiry \n";
   
   //create email headers
   $headers = 'From: '.$email. "\r\n" .
   'Reply-To: ' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

   //send
   $send = mail("[email protected]","Online Enquiry",$body,$headers);

?>

<?
if($_POST["send"]) {

   //collect post variables
   $name = $_POST["name"];
   $email = $_POST["email"];


   //build email body
   $body .= "Name: $name \n";
   $body .= "Thank you for your Enquiry \n";

   
   //create email headers
   $headers = "From: '[email protected]' \r\n".
   'Reply-To: ' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

   //send
   $send = mail("$email","Online Enquiry",$body,$headers);

?>

Now I get

 

Notice: Undefined index: send in send.php on line 2

if($_POST["send"]) {

 

 

Notice: Undefined index: send in send.php on line 34

if($_POST["send"]) {

 

Full Code Below :(

 

<?
if($_POST["send"]) { 

//collect post variables
$name = $_POST["name"];
$address = $_POST["address"];
$town = $_POST["town"];
$postocde = $_POST["postocde"];
$telephone = $_POST["telephone"];
$email = $_POST["email"];
$enquiry = $_POST["enquiry"];


//build email body
$body .= "Name: $name \n";
$body .= "Address: $address \n";
$body .= "Town: $town \n";
$body .= "Postcode: $postcode \n";
$body .= "Telephone: $telephone \n";
$body .= "Email: $email \n";
$body .= "Enquiry: $enquiry \n";

//create email headers
$headers = 'From: '.$email. "\r\n" .
  'Reply-To: ' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

//send
$send = mail("[email protected]","Online Enquiry",$body,$headers);}

?>

<?
if($_POST["send"]) { 

//collect post variables
$name = $_POST["name"];
$email = $_POST["email"];


//build email body
$body .= "Name: $name \n";
$body .= "Thank you for your Enquiry \n";


//create email headers
$headers = "From: '[email protected]' \r\n". 
  'Reply-To: ' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

//send
$send = mail("$email","Online Enquiry",$body,$headers);}

?>

incorrect $end nearly always means you are missing a } somewhere if you open a { you have to close it somewhere.}

which it seems you have but i think  your if loop is confusing itself as you have the same if statement with two same values it doesn't know what to do.

 

$send = mail(

 

doesn't make sense either.

 

try this if the name of the submit button is send it will do something if it is input typesubmit name=submit then you need to change $_POST["send"] tp $_POST["submit"]

 

<?

header ("Location: thankyou.php");

if($_POST["send"]) { 

//collect post variables
$name = $_POST["name"];
$address = $_POST["address"];
$town = $_POST["town"];
$postocde = $_POST["postocde"];
$telephone = $_POST["telephone"];
$email = $_POST["email"];
$enquiry = $_POST["enquiry"];


//build email body
$body .= "Name: $name \n";
$body .= "Address: $address \n";
$body .= "Town: $town \n";
$body .= "Postcode: $postcode \n";
$body .= "Telephone: $telephone \n";
$body .= "Email: $email \n";
$body .= "Enquiry: $enquiry \n";

//create email headers
$headers = 'From: '.$email. "\r\n" .
   'Reply-To: ' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

//send
    mail("[email protected]","Online Enquiry",$body,$headers);



//collect post variables
$name = $_POST["name"];
$email = $_POST["email"];


//build email body
$body .= "Name: $name \n";
$body .= "Thank you for your Enquiry \n";


//create email headers
$headers = "From: '[email protected]' \r\n". 
   'Reply-To: ' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

//send
mail("$email","Online Enquiry",$body,$headers);
}
else
{        
header ("Location: index.php");
}
exit;

?>

 

not sure about your email headers etc as I am not familiar with X mailer

but this would be how i would do it assuming the submit value on your forms name is submit.

 

<?

header("Location: thankyou.php");

if($_POST["submit"]) { 

//collect post variables
$name = $_POST["name"];
$address = $_POST["address"];
$town = $_POST["town"];
$postocde = $_POST["postocde"];
$telephone = $_POST["telephone"];
$email = $_POST["email"];
$enquiry = $_POST["enquiry"];

$to = "[email protected]";
$subject = "Online Enquiry";
$MsgHeader = "From: WEBSITE NAME <[email protected]>\n";
$MsgHeader .= "MIME-Version: 1.0\n";
$MsgHeader .= "Content-type: text/html; charset=iso-8859-1";
$MsgBody = "
<html>
<head>
<title>Inquiry</title>
</head>
<body>

Name: $name <br />
Address: $address <br />
Town: $town <br />
Postcode: $postcode <br />
Telephone: $telephone <br />
Email: $email <br />
Enquiry: $enquiry <br />


</body>
</html>";
mail($to, $subject, $MsgBody, $MsgHeader);




$to = "$email";
$subject = "Online Enquiry";
$MsgHeader = "From: WEBSITE NAME <[email protected]>\n";
$MsgHeader .= "MIME-Version: 1.0\n";
$MsgHeader .= "Content-type: text/html; charset=iso-8859-1";
$MsgBody = "
<html>
<head>
<title>Inquiry</title>
</head>
<body>

$name <br />

<p>Thank you for your Enquiry.</p>


</body>
</html>";
mail($to, $subject, $MsgBody, $MsgHeader);

}
else
{        
header("Location: index.php");
}
exit;

?>

oops sorry you are right just too tired i never usually use if $_POST on any of mine just pasted around the template i have saved. that i keep having to post here to help people over and over again.

 

if($_POST["submit"]) { 

//collect post variables
$name = $_POST["name"];
$address = $_POST["address"];
$town = $_POST["town"];
$postocde = $_POST["postocde"];
$telephone = $_POST["telephone"];
$email = $_POST["email"];
$enquiry = $_POST["enquiry"];

header ("Location: thankyou.php");

$to = "[email protected]";

 

header is usually there on my script sorry

in the last post i said just move the header

 

so you are saying this will do nothing?

 

<?

header("Location: thankyou.php");

if($_POST["submit"]) { 

//collect post variables
$name = $_POST["name"];
$address = $_POST["address"];
$town = $_POST["town"];
$postocde = $_POST["postocde"];
$telephone = $_POST["telephone"];
$email = $_POST["email"];
$enquiry = $_POST["enquiry"];


header("Location: thankyou.php");

$to = "[email protected]";
$subject = "Online Enquiry";
$MsgHeader = "From: WEBSITE NAME <[email protected]>\n";
$MsgHeader .= "MIME-Version: 1.0\n";
$MsgHeader .= "Content-type: text/html; charset=iso-8859-1";
$MsgBody = "
<html>
<head>
<title>Inquiry</title>
</head>
<body>

Name: $name <br />
Address: $address <br />
Town: $town <br />
Postcode: $postcode <br />
Telephone: $telephone <br />
Email: $email <br />
Enquiry: $enquiry <br />


</body>
</html>";
mail($to, $subject, $MsgBody, $MsgHeader);




$to = "$email";
$subject = "Online Enquiry";
$MsgHeader = "From: WEBSITE NAME <[email protected]>\n";
$MsgHeader .= "MIME-Version: 1.0\n";
$MsgHeader .= "Content-type: text/html; charset=iso-8859-1";
$MsgBody = "
<html>
<head>
<title>Inquiry</title>
</head>
<body>

$name <br />

<p>Thank you for your Enquiry.</p>


</body>
</html>";
mail($to, $subject, $MsgBody, $MsgHeader);

}
else
{        
header("Location: index.php");
}
exit;

?>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.