Jump to content

Problem with end of mail php file for contact form


chucknology

Recommended Posts

I'm using a contact form with verification/send php file but I always get an error on the last line. Seems the file ain't closed like it should but I can't find what's wrong. Any help is welcome.

 

<?php
if(isset($_POST['submit'])) {

$to = "[email protected]";
$mailFrom = htmlspecialchars($_POST['Email']);
$subject = "Bericht van Liberty Studio website";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$thankyou = "thankyou.htm";


/*$body = "Van: $name_field\n E-Mail: $email_field\n Bericht:\n $message";*/

;if($email == ""){
?>
No email address added. Please go back.<br/>
<?php
;}elseif($name == ""){
?>
No name added. Please go back.<br/>
<?php
;}elseif($message == ""){
?>
No message added. Please go back.<br/>
<?php
;}else{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
<meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
"<?php
}
"?>

OK, posting the error you receive would be helpful but just had a look through the entire code and there's extra code in there that really isn't required and is probably causing the error:

 

Change:

 

{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
<meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>"">
"<?php
}
"?>

 

to:

 

{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");

<meta http-equiv="refresh" content="0; url=<?echo $thankyou;?>">

}
?>

This is the error I get: Parse error: syntax error, unexpected $end in /home/chucknolog/domains/chucknology.be/public_html/libertystudio/mail.php on line 38

 

After changing what you proposed I get the error: Parse error: syntax error, unexpected '<' in /home/chucknolog/domains/chucknology.be/public_html/libertystudio/mail.php on line 35

You're also mixing standard and short tags together - perhaps your server has shorttags turned off?

 

Change:

 

url=<?echo $thankyou;?>

 

to:

 

url=<?php echo $thankyou; ?>

 

Full Code (with changes):

 

<?php
if(isset($_POST['submit'])) {

$to = "[email protected]";
$mailFrom = htmlspecialchars($_POST['Email']);
$subject = "Bericht van Liberty Studio website";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$thankyou = "thankyou.htm";


/*$body = "Van: $name_field\n E-Mail: $email_field\n Bericht:\n $message";*/

;if($email == ""){
?>
No email address added. Please go back.<br/>
<?php
;}elseif($name == ""){
?>
No name added. Please go back.<br/>
<?php
;}elseif($message == ""){
?>
No message added. Please go back.<br/>
<?php
;}else{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
<meta http-equiv="refresh" content="0; url=<?php echo $thankyou; ?>">
<?php
}
?>

Hi chucknology,

 

Just taken another look and you're missing a final curly braket at the end of the script.  CHange your code to read:

 

<?php
if(isset($_POST['submit'])) {

$to = "[email protected]";
$mailFrom = htmlspecialchars($_POST['Email']);
$subject = "Bericht van Liberty Studio website";
$name_field = $_POST['name'];
$email_field = $_POST['email'];
$message = $_POST['message'];
$thankyou = "thankyou.htm";


/*$body = "Van: $name_field\n E-Mail: $email_field\n Bericht:\n $message";*/

;if($email == ""){
?>
No email address added. Please go back.<br/>
<?php
;}elseif($name == ""){
?>
No name added. Please go back.<br/>
<?php
;}elseif($message == ""){
?>
No message added. Please go back.<br/>
<?php
;}else{

$msg = ereg_replace("\\\'", "'", $message);
$msg = ereg_replace('\\\"', "\"", $msg);
$message1 = "from: $name\nemail: $email\nmessage:\n$msg1";

mail($youremail, $subject, $msg, "From: $email\r\nReply-to: $email\r\n");
?>
<meta http-equiv="refresh" content="0; url=<?php echo $thankyou; ?>">
<?php
}
}
?>

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.