mantona Posted December 11, 2007 Share Posted December 11, 2007 It's my first time creating a form so I've probably done everything wrong. I copied this process.php from a website but cannot get it to work as it comes up with parse error on line 12. Can someone help please. *** COPY OF PROCESS.PHP BELOW *** <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> <?php // this sets up your email headers, just change the email address $headers = "From: "[email protected]\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // this emails you the results of the form mail( "[email protected]", "New Contact Message", print_r( $_POST, true),"$headers"> // this will redriect the user somewhere away from this page header("location: http://www.stmagnusbayhotel.co.uk/thanks.html"); ?> </body> </html> Thank you Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/ Share on other sites More sharing options...
revraz Posted December 11, 2007 Share Posted December 11, 2007 Well for one, your php header won't work because you have HTML already at the top. Second this line is wrong mail( "[email protected]", "New Contact Message", print_r( $_POST, true),"$headers"> You have a > at the end instead of a ) and no semi colon. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-411955 Share on other sites More sharing options...
marcus Posted December 11, 2007 Share Posted December 11, 2007 The errors start at the first line of his PHP coding. He has inescaped strings. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-411958 Share on other sites More sharing options...
mantona Posted December 11, 2007 Author Share Posted December 11, 2007 I have changed the items you mentioned. There is no html and now there is also ); at the end of the line you spoke about Unfortunately the php still does not work and gives an error: Parse error: parse error, unexpected T_STRING in /homepages/46/d134203705/htdocs/stmagnus/process.php on line 4 What are inescaped strings? Here is my code again now: <?php // this sets up your email headers, just change the email address $headers = "From: "[email protected]\r\n" . 'X-Mailer: PHP/' . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // this emails you the results of the form mail( "[email protected]", "New Contact Message", print_r( $_POST, true),"$headers"); // this will redriect the user somewhere away from this page header("location: http://www.stmagnusbayhotel.co.uk/thanks.html"); ?> Thank you for your help Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-411967 Share on other sites More sharing options...
mantona Posted December 11, 2007 Author Share Posted December 11, 2007 I also believe that the / (slash) symbol does not show up when copying onto this forum. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-411971 Share on other sites More sharing options...
p2grace Posted December 11, 2007 Share Posted December 11, 2007 Try this: $headers = "From: [email protected]\r\n" . "X-Mailer: PHP" . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // this emails you the results of the form mail( "[email protected]", "New Contact Message", print_r( $_POST, true),"$headers"); // this will redriect the user somewhere away from this page header("location: http://www.stmagnusbayhotel.co.uk/thanks.html"); ?> Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-411990 Share on other sites More sharing options...
mantona Posted December 11, 2007 Author Share Posted December 11, 2007 Thank you very much for your help. The form work until it is meant to redirect to the thanks.html page then it comes up with: on the screen and thats it. Can this be fixed easily? Also just as a curiosity, does every email get sent via my business email address? Is this open from abuse by spammers? e.g. where it says from: How does it work? Thank you again, your help appreciated. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412001 Share on other sites More sharing options...
p2grace Posted December 11, 2007 Share Posted December 11, 2007 The redirect should be: header("Location: http://www.stmagnusbayhotel.co.uk/thanks.html"); The email from address will be what you specified in the headers, and is sent by the server. It will only send from your business email address if that's what you specify in the From Address. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412005 Share on other sites More sharing options...
p2grace Posted December 11, 2007 Share Posted December 11, 2007 Also note, the redirect will only work if the headers haven't already been established. The processing needs to take place before the html headers are set. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412009 Share on other sites More sharing options...
mantona Posted December 11, 2007 Author Share Posted December 11, 2007 Still not working. This is how I've got it typed up. I do not have html headers in the process.php file. I'm not really sure what you mean.: <?php $headers = "From: [email protected]\r\n" . "X-Mailer: PHP" . phpversion() . "\r\n" . "MIME-Version: 1.0\r\n" . "Content-Type: text/html; charset=utf-8\r\n" . "Content-Transfer-Encoding: 8bit\r\n\r\n"; // this emails you the results of the form mail( "[email protected]", "New Contact Message", print_r( $_POST, true),"$headers"); // this will redriect the user somewhere away from this page header("Location: http://www.stmagnusbayhotel.co.uk/thanks.html"); ?> I've tried altering a few things but does not help. It still just re-directs to page titled: http://www.stmagnusbayhotel.co.uk/process.php with onscreen Thank you Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412012 Share on other sites More sharing options...
mantona Posted December 11, 2007 Author Share Posted December 11, 2007 That should have read: [ PHP ] [ /PHP ] onscreen Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412018 Share on other sites More sharing options...
p2grace Posted December 11, 2007 Share Posted December 11, 2007 Remove the html from the top of the file, the headers are set there. Remove: <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"> <html> <head> <title>Untitled Document</title> <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"> </head> <body> keep the php code Remove </body> </html> The only thing in the processing page should be the php code. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412019 Share on other sites More sharing options...
mantona Posted December 11, 2007 Author Share Posted December 11, 2007 Thank you very much. This form now works. Can I ask your opinion please? Do you think that it is a good idea to send from my email address like that? Does it matter? Are there better options? Thank you once again for helping me sort out the form issue Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412022 Share on other sites More sharing options...
revraz Posted December 11, 2007 Share Posted December 11, 2007 It should be a valid From email, but you may want to create a new email for that purpose, one that has a good spam filter. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412024 Share on other sites More sharing options...
p2grace Posted December 11, 2007 Share Posted December 11, 2007 Your welcome, and I think it's alright, it's a standard method of sending email. Quote Link to comment https://forums.phpfreaks.com/topic/81187-solved-please-help-me-php-form-question/#findComment-412025 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.