Jump to content

My php form is producing an error message


jonnyroboto

Recommended Posts

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.

 

phpCode.jpg

 

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

Link to comment
Share on other sites

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 ?>

Link to comment
Share on other sites

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:

 

phpCode2.jpg

 

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

Link to comment
Share on other sites

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..

Link to comment
Share on other sites

<?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" );
?>

Link to comment
Share on other sites

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....

Link to comment
Share on other sites

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

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.