E_Gruber Posted February 18, 2009 Share Posted February 18, 2009 Hi, I posted this already on another thread but I'll start my own just incase... I have an html contact form that I'm trying to create a working php script for. I'm having a few difficulties... partly because I'm very new at this... well mostly because of that! When I try to submit the contact form I get this error... Warning: Unexpected character in input: '\' (ASCII=92) state=1 in /home8/zomglawl/public_html/ericgruber.net/mailer.php on line 9 Parse error: syntax error, unexpected T_IF in /home8/zomglawl/public_html/ericgruber.net/mailer.php on line 10 Please be gentle because this is all new to me... Here's the script... <?php if(isset($_POST["submit"])) { $to = "you@yourdomain.net"; $subject = "Contact from website"; $name_field = $_POST[ "name"]; $email_field = $_POST[ "email"]; $city_field = $_POST[ "city"]; $state_field = $_POST[ "state"]; $phone_field = $_POST[ "phone"]; $message = $_POST[ "message"]; $body = "From: $name_field \n E-Mail: $email_field \n City: $city_field \n State: $state_field \n Phone: $phone_field \n Message: Message: $message \n "; echo "Data has been submitted to $to!"; mail($to, $subject, $body); } else { echo "blarg!"; } ?> Here's my html form... <form method="post" action="mailer.php"> <table style="margin-bottom: 0pt;" cellspacing="0"> <tbody> <tr> <td width="150">Name<span class="required"> *</span></td> <td><input name="Name" type="text"></td> </tr> <tr> <td>Email<span class="required"> *</span></td> <td><input name="Email" type="text"></td> </tr> <tr> <td>City</td> <td><input name="City" type="text"></td> </tr> <tr> <td>State</td> <td><input name="State" type="text"></td> </tr> <tr> <td>Phone<span class="required"> *</span></td> <td><input name="Phone" size="12" maxlength="12" type="text"></td> </tr> <tr> <td>Comment<span class="required"> *<br> <br> <br> <br> <br> </span></td> <td><textarea name="Comment" cols="40" rows="6"></textarea></td> </tr> <tr> <td><input name="Submit" value="Submit" type="submit"></td> <td> </td> </tr> </tbody> </table> </form> Thank you... Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/ Share on other sites More sharing options...
genericnumber1 Posted February 18, 2009 Share Posted February 18, 2009 There's no syntax errors in the code you posted. Did you perhaps leave some code out, or maybe uploaded the wrong file or upload to the wrong directory (happens quite often surprisingly enough)? Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/#findComment-765486 Share on other sites More sharing options...
jackpf Posted February 18, 2009 Share Posted February 18, 2009 addslashes may be turned off when posting/getting in your PHP config? Try putting addslashes() round each of your posts and see what that does... Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/#findComment-765591 Share on other sites More sharing options...
premiso Posted February 18, 2009 Share Posted February 18, 2009 addslashes may be turned off when posting/getting in your PHP config? Try putting addslashes() round each of your posts and see what that does... It should be turned off as it is being depreciated. Since he is not doing any db insert, this is how it should be. Just so you know as an fyi. Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/#findComment-765595 Share on other sites More sharing options...
jackpf Posted February 18, 2009 Share Posted February 18, 2009 Ahh. I didn't actually read the code properly, I thought he was inserting something into a database. My bad, I should pay more attention Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/#findComment-765597 Share on other sites More sharing options...
E_Gruber Posted February 18, 2009 Author Share Posted February 18, 2009 Not sure if I left code out... I'm not completely sure what I'm doing wrong. I'm using examples to create my own script... I may have missed something. As far as uploading it to the wrong directory, I have it in the root directory with the html page. Is that wrong? Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/#findComment-765650 Share on other sites More sharing options...
E_Gruber Posted February 18, 2009 Author Share Posted February 18, 2009 Also... do I keep the script in it's own ".php" file, or should I incorporate it into the web-page? Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/#findComment-765653 Share on other sites More sharing options...
Q695 Posted February 18, 2009 Share Posted February 18, 2009 I like to use mysql_real_escape_string ( $var ) to guarantee safety when sending things places. Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/#findComment-765668 Share on other sites More sharing options...
jackpf Posted February 19, 2009 Share Posted February 19, 2009 I like to use mysql_real_escape_string ( $var ) to guarantee safety when sending things places. He's not actually inserting anything into a database, as was pointed out to me before. Why have you got them spaces in $_POST[" blah"]? You could try taking them out, they're not supposed to be there. Quote Link to comment https://forums.phpfreaks.com/topic/145792-php-contact-form-help/#findComment-765690 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.