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("test@domain.com","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: 'test@domain.com' \r\n".
   'Reply-To: ' . "\r\n" .
   'X-Mailer: PHP/' . phpversion();

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

?>

Link to comment
Share on other sites

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("test@domain.com","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: 'test@test.com' \r\n". 
  'Reply-To: ' . "\r\n" .
  'X-Mailer: PHP/' . phpversion();

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

?>

Link to comment
Share on other sites

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("test@domain.com","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: 'test@test.com' \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

Link to comment
Share on other sites

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 = "info@domain.com";
$subject = "Online Enquiry";
$MsgHeader = "From: WEBSITE NAME <test@domain.com>\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 <test@domain.com>\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;

?>

Link to comment
Share on other sites

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 = "info@domain.com";

 

header is usually there on my script sorry

Link to comment
Share on other sites

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 = "info@domain.com";
$subject = "Online Enquiry";
$MsgHeader = "From: WEBSITE NAME <test@domain.com>\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 <test@domain.com>\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;

?>

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.