chucknology Posted September 24, 2009 Share Posted September 24, 2009 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 } "?> Link to comment https://forums.phpfreaks.com/topic/175335-problem-with-end-of-mail-php-file-for-contact-form/ Share on other sites More sharing options...
Bricktop Posted September 24, 2009 Share Posted September 24, 2009 Hi chucknology, On your very last line change: "?> to: ?> Hope this helps. Link to comment https://forums.phpfreaks.com/topic/175335-problem-with-end-of-mail-php-file-for-contact-form/#findComment-924013 Share on other sites More sharing options...
chucknology Posted September 24, 2009 Author Share Posted September 24, 2009 Doesn't change a thing. Link to comment https://forums.phpfreaks.com/topic/175335-problem-with-end-of-mail-php-file-for-contact-form/#findComment-924015 Share on other sites More sharing options...
Bricktop Posted September 24, 2009 Share Posted September 24, 2009 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;?>"> } ?> Link to comment https://forums.phpfreaks.com/topic/175335-problem-with-end-of-mail-php-file-for-contact-form/#findComment-924019 Share on other sites More sharing options...
chucknology Posted September 24, 2009 Author Share Posted September 24, 2009 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 Link to comment https://forums.phpfreaks.com/topic/175335-problem-with-end-of-mail-php-file-for-contact-form/#findComment-924029 Share on other sites More sharing options...
Bricktop Posted September 24, 2009 Share Posted September 24, 2009 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 } ?> Link to comment https://forums.phpfreaks.com/topic/175335-problem-with-end-of-mail-php-file-for-contact-form/#findComment-924030 Share on other sites More sharing options...
chucknology Posted September 24, 2009 Author Share Posted September 24, 2009 Changed the code but still an error on the last line. I'm waiting for an answer from my hsting regarding shorttags. Thanks allready for the support. Link to comment https://forums.phpfreaks.com/topic/175335-problem-with-end-of-mail-php-file-for-contact-form/#findComment-924056 Share on other sites More sharing options...
Bricktop Posted September 24, 2009 Share Posted September 24, 2009 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 } } ?> Link to comment https://forums.phpfreaks.com/topic/175335-problem-with-end-of-mail-php-file-for-contact-form/#findComment-924062 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.