jonnyroboto Posted April 17, 2009 Share Posted April 17, 2009 Hi, I'm trying to use a php form on the contact-us page of my website. I have a sendmail.php doc that processes the script, and I'm trying to apply a captcha code from reCaptcha, so I have a library php doc as well. These files are all located in my cgi folder on the server but I'm getting an error message that reads: Parse error: parse error in /www/cgi/form.php on line 2 when I try to test the form. All the other phps seem to be working except this one. Can anyone see how I'm getting this error message from the code I've provided? Can someone help me figure this out? Thank you, JonnyRoboto Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/ Share on other sites More sharing options...
meomike2000 Posted April 17, 2009 Share Posted April 17, 2009 you have html inside the php tag see this is what you have 1 <?php 2 <form method="post" action=" "> then you even started another <?php tag try this instead <?php echo ' <form method="post" action=" "> '; ?> when inside php you can use echo and then put your html inside quotes 'html here'; or you can do as you started and <?php php code here ?> html code here <?php more php here ?> Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812541 Share on other sites More sharing options...
jonnyroboto Posted April 17, 2009 Author Share Posted April 17, 2009 Thank you, that solved the problem with my form. I'm actually getting to the point where I can enter info into the form and validate it using the captcha. The code I'm using for the processing page is: Line 21 is the one that reads: header( "Location: http://www.wdwvip.com/thankyou.htm" ); and I'm getting an error message that reads: Warning: Cannot add header information - headers already sent by (output started at /www/cgi/sendmail.php:15) in /www/cgi/sendmail.php on line 21 What I'm trying to do is send my guests to a thank you page after they fill out the form. Is there a better way to do this? Thank you, JonnyRoboto Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812578 Share on other sites More sharing options...
meomike2000 Posted April 17, 2009 Share Posted April 17, 2009 is there something that displays out on the page before this header,,, header("location: "); can not have no output before it....... question: can u show the entire page.... Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812580 Share on other sites More sharing options...
jonnyroboto Posted April 17, 2009 Author Share Posted April 17, 2009 the entire page of code? the code I just showed you? Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812583 Share on other sites More sharing options...
meomike2000 Posted April 17, 2009 Share Posted April 17, 2009 anything that comes before the header.... please put between code tags on here..... put code here please.... the # up above where u type ur post is for code.... please remove any sensitive things from code before you copy and paste it here. like passwords, etc... thanks will help.. Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812594 Share on other sites More sharing options...
jonnyroboto Posted April 17, 2009 Author Share Posted April 17, 2009 <?php require_once('recaptchalib.php'); $privatekey = "..."; $resp = recaptcha_check_answer ($privatekey, $_SERVER["REMOTE_ADDR"], $_POST["recaptcha_challenge_field"], $_POST["recaptcha_response_field"]); if (!$resp->is_valid) { die ("The reCAPTCHA wasn’t entered correctly. Go back and try it again." . "(reCAPTCHA said: " . $resp->error . ")"); } ?> <?php $email = $_REQUEST['email'] ; $message = $_REQUEST['message'] ; mail( "jgravato@gmail.com", "Contact Form", $message, "From: $email" ); header( "Location: http://www.wdwvip.com/thankyou.htm" ); ?> Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812598 Share on other sites More sharing options...
meomike2000 Posted April 17, 2009 Share Posted April 17, 2009 not real sure,,, try taking the php close tag and then another start tag out and just let it all be one script like this <?php code code code ?> and not <?php code ?> <?php code ?> not sure that it makes a diff or not but there is no need to do it that way that i am aware of.... Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812605 Share on other sites More sharing options...
jonnyroboto Posted April 17, 2009 Author Share Posted April 17, 2009 WOW! It worked! Thank you so much! The only reason I did it the other way was because it was two different pieces of code. the top was the validation for the captcha and the bottom was to process the form and send my clients to a thanks page. Thank you for your help, JonnyRoboto Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812608 Share on other sites More sharing options...
meomike2000 Posted April 17, 2009 Share Posted April 17, 2009 in my view a script is a script no matter how many parts it has...... Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812610 Share on other sites More sharing options...
jonnyroboto Posted April 17, 2009 Author Share Posted April 17, 2009 i have a final question, if you don't mind me asking. I am trying to include this form into an htm page. would I just simply use an "include" for this? Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812660 Share on other sites More sharing options...
meomike2000 Posted April 17, 2009 Share Posted April 17, 2009 just use include 'filename'; you can add html to the php page with echo 'htmlcode here'; code code echo 'htmlcode here'; you can do that as well. Quote Link to comment https://forums.phpfreaks.com/topic/154528-my-php-form-is-producing-an-error-message/#findComment-812700 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.