PirateBagel Posted February 12, 2007 Share Posted February 12, 2007 I'm just trying to make a simple form. It works for the most part, when its up. But now I get this error: Parse error: syntax error, unexpected $end in /data/12/1/9/96/1172911/user/1246821/htdocs/forms/contact.php on line 22 Now, line 22 of that file is just the closing ?> Did I not define something? Is that the wrong way to end it? Here's the website: http://017b5a6.netsolhost.com/forms/contact.php I'm pretty sure the problem lies within contact.php, but I'll post the other segments of the program. Email or respond if you need any more info. Heres the code: contact.php <? include('config.inc'); if ($_SERVER['REQUEST_METHOD'] == "POST") { $name = $_POST[name]; $email = $_POST[email]; $company = $_POST[company]; $phone = $_POST[phone]; $website = $_POST[website]; $msg = $_POST[msg]; $subject = $_POST[subject]; // $msg2 is set in config.inc which formats the body of the message mail("[email protected]", "$subjectheader $subject", "$msg2", "From: $email \nReply-To: $email"); if ($redirecturl != "") { header("Location: $redirecturl"); include("contactform.php"); ?> Config.inc <? $scriptname = "Contact Form"; $script_dir = "/home/www/017b5a6.netsolhost.com/htdocs/forms/ContactForm"; $script_url = "017b5a6.netsolhost.com"; $subjectheader = "[Contact Form]:"; $redirecturl = "http://www.arborpronw.com"; $msg2 = "Name: $name Email: $email Company: $company Phone: $phone Website: $website Message:$msg"; ?> contactform.php <SCRIPT LANGUAGE="JavaScript"> <!-- Hide code from non-js browsers function validate() { formObj = document.contact; if ((formObj.name.value == "") || (formObj.email.value == "") || (formObj.subject.value == "") || (formObj.msg.value == "")) { alert("You have not filled in all required fields."); return false; } else { alert('Thank you for filling out our online estimate, we will reply to you as soon as possible! Please wait 5 seconds after clicking "OK" to make sure the data sends properly.'); return true; } } // end hiding --> </SCRIPT> <TABLE BORDER=0 cellpadding=5 cellspacing=0> <TR> <TD> <TABLE BORDER=0 cellpadding=2 cellspacing=0> <form action="contact.php" method="post" name="contact" onSubmit="return validate()"> <TR> <TD> <BR> <DIV> 1. Name *<BR> <input type=text value='your name' size=50 maxlength=50 name=name class='txtfield'><BR> 2. Email Adress *<BR> <input type='text' value='[email protected]' size='50' maxlength='60' name='email'><BR> 3. Company Name<BR> <input type='text' value='your company' size='50' maxlength='50' name='company'><BR> 4. Phone Number<BR> <input type='text' value='(000) 000-0000' size='50' maxlength='32' name='phone'><BR> 5. Webiste<BR> <input type='text' value='http://applepedia.dap.ro/?cat=9' size='50' maxlength='60' name='website'><BR> 6. Email to *<BR> <select name='who'> <option value='1'>Customer Service</option> </select><BR> 7. Subject *<BR> <input type='text' value='' size='50' maxlength='60' name='subject'><BR> 8. Message *<BR> <textarea name='msg' rows='7' cols='50'></textarea><BR> </DIV> <input type='submit' value='submit'>* Field Required<BR> </TD> </tR> </FORM> </tABLE> </TD> </TR> </tABLE> Link to comment https://forums.phpfreaks.com/topic/38231-unexpected-end-simple-code-dont-know-whats-wrong/ Share on other sites More sharing options...
Jessica Posted February 12, 2007 Share Posted February 12, 2007 if ($redirecturl != "") { header("Location: $redirecturl"); include("contactform.php"); Unclosed if{ brackets. Link to comment https://forums.phpfreaks.com/topic/38231-unexpected-end-simple-code-dont-know-whats-wrong/#findComment-183122 Share on other sites More sharing options...
PirateBagel Posted February 12, 2007 Author Share Posted February 12, 2007 if ($redirecturl != "") { header("Location: $redirecturl"); include("contactform.php"); Unclosed if{ brackets. I knew it was something simple. Gah, im still learning PHP: How would I go about fixing it? If I change it to if ($redirecturl != "") { header("Location: $redirecturl"); } else { echo "<br><center>Thank you.. blah blah blah.</center><br>"; } It should work, correct? Link to comment https://forums.phpfreaks.com/topic/38231-unexpected-end-simple-code-dont-know-whats-wrong/#findComment-183139 Share on other sites More sharing options...
Jessica Posted February 12, 2007 Share Posted February 12, 2007 Yes. Link to comment https://forums.phpfreaks.com/topic/38231-unexpected-end-simple-code-dont-know-whats-wrong/#findComment-183146 Share on other sites More sharing options...
PirateBagel Posted February 12, 2007 Author Share Posted February 12, 2007 Alright, With this code right here it works <? include('config.inc'); if ($_SERVER['REQUEST_METHOD'] == "POST") { $name = $_POST[name]; $email = $_POST[email]; $company = $_POST[company]; $phone = $_POST[phone]; $website = $_POST[website]; $msg = $_POST[msg]; $subject = $_POST[subject]; mail("[email protected]", "$subjectheader $subject", "$msg2", "From: $email \nReply-To: $email"); } else { echo "<br><center>$finishedtext</center><br>"; } include("contactform.php"); ?> But, it wont redirect once it is done. And the code I have makes it fail, so now my question is, how do I get this to redirect? Link to comment https://forums.phpfreaks.com/topic/38231-unexpected-end-simple-code-dont-know-whats-wrong/#findComment-183156 Share on other sites More sharing options...
redarrow Posted February 12, 2007 Share Posted February 12, 2007 <?php include('config.inc'); if ($_SERVER['REQUEST_METHOD'] == "POST") { $name = $_POST[name]; $email = $_POST[email]; $company = $_POST[company]; $phone = $_POST[phone]; $website = $_POST[website]; $msg = $_POST[msg]; $subject = $_POST[subject]; mail("[email protected]", "$subjectheader $subject", "$msg2", "From: $email \nReply-To: $email"); //if all correct redirect. header("location: what_ever.php"); } else { echo "<br><center>$finishedtext</center><br>"; } include("contactform.php"); ?> Link to comment https://forums.phpfreaks.com/topic/38231-unexpected-end-simple-code-dont-know-whats-wrong/#findComment-183159 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.