tspx Posted March 13, 2011 Share Posted March 13, 2011 Need help trying to get a form working. Tried to put this on a site, but when I hit submit, nothing happens. Here's the form: <form name="cform" method="post" action="contactformprocess.php"> <p><label for="customer">Name:</label><br /> <input type="text" name="customer" id="customer" size="40"/></p> <p><label for="address">Email Address:</label><br /> <input type="text" name="address" id="address" size="40" /><br /></p> <p><label for="landline">Telephone Number:</label><br /> <input type="text" name="landline" id="landline" size="40"/></p> <p><label for="comment">Please tell us what you need:</label><br /> <textarea title="Tell Us About Your Idea" name="comment" id="comment" rows="5" cols="50" class="input"></textarea><br /></p> <p><input type="button" name="Submit" value="Submit" title="Sumbit" height="28" width="97" border="0" alt="Submit"></p> </form> and here's the PHP: <?php /* subject and email variables */ $emailSubject = 'Spark Inquiry'; $webMaster = '[email protected]'; /* Data Variables */ $name = $_POST['customer']; $email = $_POST['address']; $phone = $_POST['landline']; $comments = $_POST['comment']; $submit = $_POST['Submit']; $body = <<<EOD <br><hr><br> Name: $name <br> Email: $email <br> Phone: $phone <br> Help: $help <br> Comments: $comments <br> EOD; $headers = "$From: $email\r\n"; $headers .-"Content-type: text\html\r\n"; $success - mail($webMaster, $emailSubject, $body, $headers); /* Redirect */ $theResults <<<EOD <html> <head> <title>SparkMedia - Thanks!</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> <style type="text/css"> <!-- body { background-color: #f1f1f1; font-family: Verdana, Arial, Helvetica, sans-serif; font-size: 12px; font-style: normal; line-height: normal; font-weight: normal; color: #666666; text-decoration: none; } --> </style> </head> <div> <div align="left">Thank you for your interest! Your email will be answered soon!</div> </div> </body> </html> EOD; echo "$theResults"; ?> Any help? Quote Link to comment https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/ Share on other sites More sharing options...
DavidAM Posted March 13, 2011 Share Posted March 13, 2011 What does "nothing happens" mean? Does the browser attempt to load the PHP script? Do you get any error messages? Do you get a blank screen? I do see two lines in that code that could be causing problems: $headers .-"Content-type: text\html\r\n"; $success - mail($webMaster, $emailSubject, $body, $headers); Shouldn't that be: $headers .= "Content-type: text\html\r\n"; $success = mail($webMaster, $emailSubject, $body, $headers); Quote Link to comment https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/#findComment-1187168 Share on other sites More sharing options...
tspx Posted March 13, 2011 Author Share Posted March 13, 2011 What does "nothing happens" mean? Does the browser attempt to load the PHP script? Do you get any error messages? Do you get a blank screen? Nothing, as in, it doesn't do anything. http://sparkmediawebdesign.com/spark/contact.php try it. Quote Link to comment https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/#findComment-1187173 Share on other sites More sharing options...
anevins Posted March 13, 2011 Share Posted March 13, 2011 Have you had this form working before? What I would expect to see is something like: if(isset($_POST['Submit'])){ echo 'something'; // send your email etc. } Quote Link to comment https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/#findComment-1187177 Share on other sites More sharing options...
tspx Posted March 13, 2011 Author Share Posted March 13, 2011 nope. this is new. Quote Link to comment https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/#findComment-1187178 Share on other sites More sharing options...
DavidAM Posted March 14, 2011 Share Posted March 14, 2011 Have a look at your generated HTML (view page source). Your page starts with a DOCTYPE, HTML open tag and HEAD section, then there is another DOCTYPE, HTML open tag and HEAD section INSIDE the BODY. In fact, there is a second BODY inside that BODY as well. The form you are having trouble with appears AFTER the closing BODY and closing HTML tags. I'm sure this confuses the browser no end. Clean up the code you generate and see if that fixes the form. Quote Link to comment https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/#findComment-1187192 Share on other sites More sharing options...
trinaryoc Posted March 14, 2011 Share Posted March 14, 2011 hey change your button type to "type='submit'" and that should fix your issue... Edit: Yeah just tested it... change your button type.... But now after the submit you're getting : Parse error: syntax error, unexpected T_START_HEREDOC in D:\Hosting\7467142\html\spark\contactformprocess.php on line 32 Quote Link to comment https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/#findComment-1187201 Share on other sites More sharing options...
trinaryoc Posted March 14, 2011 Share Posted March 14, 2011 The error code is caused because you're missing a '=' before the <<<EOD. Quote Link to comment https://forums.phpfreaks.com/topic/230554-need-help-with-a-form/#findComment-1187208 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.