Recaptcha works | Wont submit | ThankYou.php

How do I get my page to move to the next page after everything is verified, including the Recaptcha variables!   The website contact page address is http://www.robmcintosh.net/contact.php

How do I get Recaptcha and my PHP verification code to work together?

How does my contact page get to the Thank You page?

 header("Location: http://www.robmcintosh.net/thankyou.php");



<?php
session_start();

//Check if the form has been submitted.
if (isset($_POST['submitted'])) {
$FULLNAME = $_POST['FULLNAME'];
$EMAIL = $_POST['EMAIL'];
$AREACODE = $_POST['AREACODE'];
$PHONE = $_POST['PHONE'];
$PHONE2 = $_POST['PHONE2'];
$COMMENTS = $_POST['COMMENTS'];


if ($FULLNAME == "") {
$redhighlighted1 = "redhighlighted\n";
} if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EMAIL)){
$redhighlighted2 = "redhighlighted\n"; 
$errormsg.="<strong style='color:#FF0000; font-size:11px;'>Email address needs '@' and period.</strong> <br><br>";
} if ($COMMENTS == ""){
$redhighlighted3 = "redhighlighted\n";
} else {
if($redhighlighted1 == "" && $redhighlighted2 == "" && $redhighlighted3 == "") 
{$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($newlocation),"/"));

header("Location: http://www.robmcintosh.net/thankyou.php");
break;
}
}
} //End of main isset() IF.

// Leave the PHP section and create the HTML form.
?>

Open in new window

RobWellsMcAsked:
Who is Participating?
 
dactechsConnect With a Mentor Commented:
Use

ob_start();

as the first line of your php code.

If any output *at all* (even a space character) is sent to the browser before calling

header("Location: http://www.robmcintosh.net/thankyou.php");

you will not get a redirect, and will most likely get a "Headers already sent..." error.



Many folks tend to take the recaptcha example code too literally.

The "require"  and key definitions should probably appear near the top of the code, maybe just after the session_start();

 The
        if ($_POST["recaptcha_response_field"]
code block needs to be inside the
        if (isset($_POST['submitted']))
code block along with the rest of your form validation.

The   echo recaptcha_get_html($publickey, $error);   statement
just needs to be somewhere inside your form, which you've got fine.
0
 
RobWellsMcAuthor Commented:
Here's what the XHTML form looks like:
<form action="" method="post">

<div class="rowfloats requiredrow">
<label class="entryWidth requiredBold" for="FULLNAME">Full Name*</label>
<input id="FULLNAME" name="FULLNAME" type="text" class="<?php print "$redhighlighted1"; ?>" size="34" title="Full name required" value="<?php if(isset($_POST['FULLNAME'])) echo $_POST['FULLNAME']; ?>" />
</div>
<div class="rowfloats requiredrow">
	<label class="entryWidth requiredBold" for="EMAIL">Email*</label>
	<input id="EMAIL" name="EMAIL" type="text" class="<?php print "$redhighlighted2"; ?>" title="Email required" value="<?php if(isset($_POST['EMAIL'])) echo $_POST['EMAIL']; ?>" size="34" />
</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;">xxxxxxxxx@anysite.com</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;"><?php print $errormsg; ?></div>
<div class="rowfloats">
	<label class="entryWidth" for="AREACODE">Phone</label>
	<input type=text name="AREACODE" size="3" maxlength="3" value="<?php if(isset($_POST['AREACODE'])) echo $_POST['AREACODE']; ?>"  onKeyUp="return autoTab(this, 3, event);" /> - <input type=text name="PHONE" size="3" maxlength="3" onKeyUp="return autoTab(this, 3, event);" value="<?php if(isset($_POST['PHONE'])) echo $_POST['PHONE']; ?>" />  <input type=text name="PHONE2" size="4" maxlength="4" onKeyUp="return autoTab(this, 4, event);" value="<?php if(isset($_POST['PHONE2'])) echo $_POST['PHONE2']; ?>" />
</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;">(xxx) xxx-xxxx</div>
<div class="rowfloats requiredrow">
	<label  class="entryWidth requiredBold " for="COMMENTS">Message*</label>
	<textarea id="COMMENTS" name="COMMENTS" cols="36" rows="8" title="Message required"class="<?php print "$redhighlighted3"; ?>"><?php if(isset($_POST['COMMENTS'])) echo $_POST['COMMENTS']; ?></textarea>
</div>

<div class="rowfloats">
<?php

require_once('recaptchalib.php');

// Get a key from http://recaptcha.net/api/getkey
$publickey = "6Lc0SwwAAAAAAFd-BZnB_H5tb3FSY97quugXvLRg ";
$privatekey = "6Lc0SwwAAAAAADJRtnabY6D_e8_cXFRD4JICGNEl ";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;

# was there a reCAPTCHA response?
if ($_POST["recaptcha_response_field"]) {
        $resp = recaptcha_check_answer ($privatekey,
                                        $_SERVER["REMOTE_ADDR"],
                                        $_POST["recaptcha_challenge_field"],
                                        $_POST["recaptcha_response_field"]);

        if ($resp->is_valid) {
                echo "You got it!";
        } else {
                # set the error code so that we can display it
                $error = $resp->error;
        }
}
echo recaptcha_get_html($publickey, $error);
?>

</div>

<div class="rowfloats"><div class="rowAutoCentered">
<input type="submit" value="Submit" class="submit" />

</div></div>
</form>

Open in new window

0
 
dactechsCommented:
There were several problems with the code, but code below seems to be working OK on my desktop.


<?php
// Start output buffering so that we can use "header();" to redirect to a different page.
ob_start();
session_start();


// Pull in recaptcha definitions here and initialize 
require_once('recaptchalib.php');

// Get a key from http://recaptcha.net/api/getkey
$publickey = "6Lc0SwwAAAAAAFd-BZnB_H5tb3FSY97quugXvLRg ";
$privatekey = "6Lc0SwwAAAAAADJRtnabY6D_e8_cXFRD4JICGNEl ";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
// Initialize you variables to values you test for when outputting for input classes.
$redhighlighted1 = '';
$redhighlighted2 = '';
$redhighlighted3 = '';
$errormsg = "";

//Check if the form has been submitted.
if (isset($_POST['submitted']))
{

// Validate recaptcha input here
   # was there a reCAPTCHA response?
   if ($_POST["recaptcha_response_field"]) {
           $resp = recaptcha_check_answer ($privatekey,
                                           $_SERVER["REMOTE_ADDR"],
                                           $_POST["recaptcha_challenge_field"],
                                           $_POST["recaptcha_response_field"]);
   
           if ($resp->is_valid) {
                   echo "You got it!";
           } else {
                   # set the error code so that we can display it
                   $error = $resp->error;
           }
   }
   $FULLNAME = $_POST['FULLNAME'];
   $EMAIL = $_POST['EMAIL'];
   $AREACODE = $_POST['AREACODE'];
   $PHONE = $_POST['PHONE'];
   $PHONE2 = $_POST['PHONE2'];
   $COMMENTS = $_POST['COMMENTS'];
   
   if ($FULLNAME == "")
   {
      $redhighlighted1 = "redhighlighted";
   }
   if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EMAIL))
   {
      $redhighlighted2 = "redhighlighted"; 
      $errormsg.="<strong style='color:#FF0000; font-size:11px;'>Email address needs '@' and period.</strong> <br><br>";
   }
   if ($COMMENTS == "")
   {
      $redhighlighted3 = "redhighlighted";
   }
   else
   {
      if($redhighlighted1 == "" && $redhighlighted2 == "" && $redhighlighted3 == "") 
      {
         //$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($newlocation),"/"));
         // With output buffering, the header statement should work now.
         header("Location: http://www.robmcintosh.net/thankyou.php");
      }
   }
} //End of main isset() IF.

// Leave the PHP section and create the HTML form.
?>


<style typ="text/css">
.redhighlighted
{
   background-color:#F99;
}
</style>



<form action="" method="post">

<div class="rowfloats requiredrow">
<label class="entryWidth requiredBold" for="FULLNAME">Full Name*</label>
<input id="FULLNAME" name="FULLNAME" type="text" class="<?php print "$redhighlighted1"; ?>" size="34" title="Full name required" value="<?php if(isset($_POST['FULLNAME'])) echo $_POST['FULLNAME']; ?>" />
</div>
<div class="rowfloats requiredrow">
	<label class="entryWidth requiredBold" for="EMAIL">Email*</label>
	<input id="EMAIL" name="EMAIL" type="text" class="<?php print "$redhighlighted2"; ?>" title="Email required" value="<?php if(isset($_POST['EMAIL'])) echo $_POST['EMAIL']; ?>" size="34" />
</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;">xxxxxxxxx@anysite.com</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;"><?php print $errormsg; ?></div>
<div class="rowfloats">
	<label class="entryWidth" for="AREACODE">Phone</label>
	<input type=text name="AREACODE" size="3" maxlength="3" value="<?php if(isset($_POST['AREACODE'])) echo $_POST['AREACODE']; ?>"  onKeyUp="return autoTab(this, 3, event);" /> - <input type=text name="PHONE" size="3" maxlength="3" onKeyUp="return autoTab(this, 3, event);" value="<?php if(isset($_POST['PHONE'])) echo $_POST['PHONE']; ?>" />  <input type=text name="PHONE2" size="4" maxlength="4" onKeyUp="return autoTab(this, 4, event);" value="<?php if(isset($_POST['PHONE2'])) echo $_POST['PHONE2']; ?>" />
</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;">(xxx) xxx-xxxx</div>
<div class="rowfloats requiredrow">
	<label  class="entryWidth requiredBold " for="COMMENTS">Message*</label>
	<textarea id="COMMENTS" name="COMMENTS" cols="36" rows="8" title="Message required"class="<?php print "$redhighlighted3"; ?>"><?php if(isset($_POST['COMMENTS'])) echo $_POST['COMMENTS']; ?></textarea>
</div>

<div class="rowfloats">
<?php


echo recaptcha_get_html($publickey, $error);
?>

</div>

<div class="rowfloats"><div class="rowAutoCentered">
<input name="submitted" type="submit" value="Submit" class="submit" />

</div></div>
</form>

Open in new window

0
Cloud Class® Course: Python 3 Fundamentals

This course will teach participants about installing and configuring Python, syntax, importing, statements, types, strings, booleans, files, lists, tuples, comprehensions, functions, and classes.

 
RobWellsMcAuthor Commented:
dactechs,

Thanks for the latest info although it didnt work the way I wanted it to work.

Is there a Recaptcha variable my PHP form can test for before submitting -
if($redhighlighted1 == "" && $redhighlighted2 == "" && $redhighlighted3 == ""

It seems my form bypassed the Recaptcha requiements in submitting the form and getting me to the thankyou.php page.

Your thoughts?  

Here's the entire code in full...
<?php
// Start output buffering so that we can use "header();" to redirect to a different page.
ob_start();
session_start();

// Pull in recaptcha definitions here and initialize 
require_once('recaptchalib.php');

// Get a key from http://recaptcha.net/api/getkey
$publickey = "6Lc0SwwAAAAAAFd-BZnB_H5tb3FSY97quugXvLRg ";
$privatekey = "6Lc0SwwAAAAAADJRtnabY6D_e8_cXFRD4JICGNEl ";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
// Initialize you variables to values you test for when outputting for input classes.
$redhighlighted1 = '';
$redhighlighted2 = '';
$redhighlighted3 = '';
$errormsg = "";

//Check if the form has been submitted.
if (isset($_POST['submitted']))
{

// Validate recaptcha input here
   # was there a reCAPTCHA response?
   if ($_POST["recaptcha_response_field"]) {
           $resp = recaptcha_check_answer ($privatekey,
                                           $_SERVER["REMOTE_ADDR"],
                                           $_POST["recaptcha_challenge_field"],
                                           $_POST["recaptcha_response_field"]);
   
           if ($resp->is_valid) {
                   echo "You got it!";
           } else {
                   # set the error code so that we can display it
                   $error = $resp->error;
           }
   }
   $FULLNAME = $_POST['FULLNAME'];
   $EMAIL = $_POST['EMAIL'];
   $AREACODE = $_POST['AREACODE'];
   $PHONE = $_POST['PHONE'];
   $PHONE2 = $_POST['PHONE2'];
   $COMMENTS = $_POST['COMMENTS'];


if ($FULLNAME == "") {
$redhighlighted1 = "redhighlighted\n";
} if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EMAIL)){
$redhighlighted2 = "redhighlighted\n"; 
$errormsg.="<strong style='color:#FF0000; font-size:11px;'>Email address needs '@' and period.</strong> <br><br>";
} if ($COMMENTS == ""){
$redhighlighted3 = "redhighlighted\n";
} else
   {
      if($redhighlighted1 == "" && $redhighlighted2 == "" && $redhighlighted3 == "") 
      {
         //$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($newlocation),"/"));
         // With output buffering, the header statement should work now.
         
$message2="
".$FULLNAME.", 
	
Thanks for contacting us and we will get back to you very soon.  \n

Thanks in advance,
	
Rob McIntosh
";

$message2 = stripslashes($message2);

mail("xxxxxxxx@yahoo.com ","Completed Rob McIntosh Contact Us Form",$message,"From:xxxxxxxx@yahoo.com");
mail($EMAIL, "Thanks For Contacting Me - I'll be in touch soon", $message2, 
"From:xxxxxxxx@yahoo.com" );

header("Location: http://www.robmcintosh.net/thankyou.php");
break;
}

}
} //End of main isset() IF.

// Leave the PHP section and create the HTML form.
?>





<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>Website Portfolio :: Rob McIntosh</title>
    <link rel="stylesheet" type="text/css" href="CSSlayout.css"></link>	
	
<script type="text/javascript" src="includes/autoTabNumbers.js"></script> 

<script>
var RecaptchaOptions = {
   theme : 'clean'
};
</script>

<style type="text/css">
div.rowfloats label.entryWidth {float:left; display:block; padding:0 6px; width:76px;}
.requiredBold {font-weight:bold;}
div.rowfloats {background:white; border:1px solid #E2E2E2; margin:0 0 5px 0; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; float:left; width:70%; padding:6px 0;}
div.rowAutoCentered {width:100%; text-align:center;}
div.requiredrow {background:white; cursor:pointer;}
div.requiredrow:hover {background:#E8E8E8; cursor:pointer;}

.redhighlighted
{
   background-color:#F99;
}

.recaptchatable .recaptcha_image_cell, #recaptcha_table {
background-color:white; !important; //reCaptcha widget background color
}
#recaptcha_table {
border-color:#444444 !important; //reCaptcha widget border color
}
#recaptcha_response_field {
border-color:#242424  !important; //Text input field border color
background-color: blue !important; //Text input field background color
}
</style>
</head>
<body>
<div id="SCREEN"><!--*1-->

<div id="ACCESSIBILITY"><div class="innerAlign">
<div class="box1"><a name="jumphere"></a><a href="#jumpcontent" class="accessibilitybarlink" title="Jump to main content">* Jump to main content</a><a href="#jumpnavigation" class="accessibilitybarlink" title="Jump to main navigation bar">*Jump to main navigation</a></div>
</div></div><!--end ACCESSIBILITY combo--> 

<div id="FOUNDATION"><!--*2-->

<div id="MASTHEAD"><div class="inner aslettmethod">
<img src="images/MASTHEAD-robmcintosh-updated.gif" width="196" alt="Rob McIntosh - Websites | Standards | Design logo" />
<div class="Nav">
<ul><li><a href="index.php">HOME</a></li><li><a href="portfolio.php">PORTFOLIO</a></li><li><a href="contact.php">CONTACT</a></li></ul></div><!--.mainNav-->
</div></div><!--end MASTHEAD combo-->


<div id="TWOCOLS-L1" class="aslettmethod"><div class="inner"><!--*3-->
<div id="PORTFOLIO"><!--*4-->

<table class="TWOCOLS-table">
<tr><td>

<div class="TWOCOLS-L2-FIRST-setwidth">


<strong>Fill out the accessible form below to contact me:</strong>
<br /><br /><br />


<form action="" method="post">

<div class="rowfloats requiredrow">
<label class="entryWidth requiredBold" for="FULLNAME">Full Name*</label>
<input id="FULLNAME" name="FULLNAME" type="text" class="<?php print "$redhighlighted1"; ?>" size="34" title="Full name required" value="<?php if(isset($_POST['FULLNAME'])) echo $_POST['FULLNAME']; ?>" />
</div>
<div class="rowfloats requiredrow">
	<label class="entryWidth requiredBold" for="EMAIL">Email*</label>
	<input id="EMAIL" name="EMAIL" type="text" class="<?php print "$redhighlighted2"; ?>" title="Email required" value="<?php if(isset($_POST['EMAIL'])) echo $_POST['EMAIL']; ?>" size="34" />
</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;">xxxxxxxxx@anysite.com</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;"><?php print $errormsg; ?></div>
<div class="rowfloats">
	<label class="entryWidth" for="AREACODE">Phone</label>
	<input type=text name="AREACODE" size="3" maxlength="3" value="<?php if(isset($_POST['AREACODE'])) echo $_POST['AREACODE']; ?>"  onKeyUp="return autoTab(this, 3, event);" /> - <input type=text name="PHONE" size="3" maxlength="3" onKeyUp="return autoTab(this, 3, event);" value="<?php if(isset($_POST['PHONE'])) echo $_POST['PHONE']; ?>" />  <input type=text name="PHONE2" size="4" maxlength="4" onKeyUp="return autoTab(this, 4, event);" value="<?php if(isset($_POST['PHONE2'])) echo $_POST['PHONE2']; ?>" />
</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;">(xxx) xxx-xxxx</div>
<div class="rowfloats requiredrow">
	<label  class="entryWidth requiredBold " for="COMMENTS">Message*</label>
	<textarea id="COMMENTS" name="COMMENTS" cols="36" rows="8" title="Message required"class="<?php print "$redhighlighted3"; ?>"><?php if(isset($_POST['COMMENTS'])) echo $_POST['COMMENTS']; ?></textarea>
</div>

<div class="rowfloats">
<?php
echo recaptcha_get_html($publickey, $error);
?>

</div>

<div class="rowfloats"><div class="rowAutoCentered">
<input name="submitted" type="submit" value="Submit" class="submit" />

</div></div>
</form>






</div><!--end TWOCOLS-L2-FIRST-->
</td><td width="36%"> <!--Dynamics btwn first & third TDs :: width vs. padding-right-->

<div class="TWOCOLS-L2-LAST"><div class="inner">
<div class="Current" style="margin-bottom:30px;">
<h2>Portfolio</h2>
Client: Function Central
Media: Website and identity
I'm designing and building templates for a site redesign of London-based events company Function Central, along with developing a new brand for them. The magnificent Fresh Monkey are building the site and providing a beautifully tailored CMS.
</div>	
</div></div><!--end TWOCOLS-L2-LAST combo-->

</td></tr>
</table>

</div><!--#PORTFOLIO *4-->
</div></div><!--#TWOCOLS-L1 combo *3-->

</div><!--#FOUNDATION *2-->


<div id="FOOTER"><div class="maximum-width"><div class="innerAlign"><p class="leftblock"> &copy; Rob McIntosh 2002-2010  &nbsp;&nbsp;Powered by:</p> <img src="images/image-dreamhost.png" height="25" width="126" />   <p class="rightblock"><a href="#" style="color:#222222;">W3C</a> | <a href="#" style="color:#222222;">XHTML</a> | <a href="#" style="color:#222222;">CSS</a> | <a href="#" style="color:#222222;">Accessibility</a> | <a href="#" style="color:#222222;">Terms of Use</a>
</p></div></div></div><!--#FOOTER duo-->

</div><!--#SCREEN *1-->

</body>
</html>

Open in new window

0
 
dactechsConnect With a Mentor Commented:
This new code I've added in a check for the captcha error in the long if statement surrounding the  redirect. You should modify the $errormsg in the pales it is set to be more meaningful to your site visitors and work on the placement of form items and error messages. Overall, I think this does what you need.
<?php
ob_start();
session_start();

// Start output buffering so that we can use "header();" to redirect to a different page.


// Pull in recaptcha definitions and initialize 
require_once('recaptchalib.php');

// Get a key from http://recaptcha.net/api/getkey
$publickey = "6Lc0SwwAAAAAAFd-BZnB_H5tb3FSY97quugXvLRg ";
$privatekey = "6Lc0SwwAAAAAADJRtnabY6D_e8_cXFRD4JICGNEl ";

# the response from reCAPTCHA
$resp = null;
# the error code from reCAPTCHA, if any
$error = null;
$redhighlighted1 = '';
$redhighlighted2 = '';
$redhighlighted3 = '';
$errormsg = "";

//Check if the form has been submitted.
if (isset($_POST['submitted']))
{
   // Validate recaptcha input here
   # was there a reCAPTCHA response?
   if ($_POST["recaptcha_response_field"]) {
           $resp = recaptcha_check_answer ($privatekey,
                                           $_SERVER["REMOTE_ADDR"],
                                           $_POST["recaptcha_challenge_field"],
                                           $_POST["recaptcha_response_field"]);
   
           if ($resp->is_valid) {
                   echo "You got it!";
           } else {
                   # set the error code so that we can display it
                   $errormsg .= $resp->error;
           }
   }
   $FULLNAME = $_POST['FULLNAME'];
   $EMAIL = $_POST['EMAIL'];
   $AREACODE = $_POST['AREACODE'];
   $PHONE = $_POST['PHONE'];
   $PHONE2 = $_POST['PHONE2'];
   $COMMENTS = $_POST['COMMENTS'];
   
   if ($FULLNAME == "")
   {
      $redhighlighted1 = "redhighlighted";
   }
   if (!eregi("^[a-z0-9]+([_\\.-][a-z0-9]+)*" ."@"."([a-z0-9]+([\.-][a-z0-9]+)*)+"."\\.[a-z]{2,}"."$",$EMAIL))
   {
      $redhighlighted2 = "redhighlighted"; 
      $errormsg.="<strong style='color:#FF0000; font-size:11px;'>Email address needs '@' and period.</strong> <br><br>";
   }
   if ($COMMENTS == "")
   {
      $redhighlighted3 = "redhighlighted";
   }
   else
   {
      if($redhighlighted1 == "" && $redhighlighted2 == "" && $redhighlighted3 == "" && empty($errormsg)) 
      {
         //$where_form_is="http".($HTTP_SERVER_VARS["HTTPS"]=="on"?"s":"")."://".$SERVER_NAME.strrev(strstr(strrev($newlocation),"/"));
         // With output buffering, the header statement should work now.
         header("Location: http://www.robmcintosh.net/thankyou.php");
      }
   }
} //End of main isset() IF.

// Leave the PHP section and create the HTML form.
?>


<style typ="text/css">
.redhighlighted
{
   background-color:#F99;
}
</style>



<form action="" method="post">

<div class="rowfloats requiredrow">
<label class="entryWidth requiredBold" for="FULLNAME">Full Name*</label>
<input id="FULLNAME" name="FULLNAME" type="text" class="<?php print "$redhighlighted1"; ?>" size="34" title="Full name required" value="<?php if(isset($_POST['FULLNAME'])) echo $_POST['FULLNAME']; ?>" />
</div>
<div class="rowfloats requiredrow">
	<label class="entryWidth requiredBold" for="EMAIL">Email*</label>
	<input id="EMAIL" name="EMAIL" type="text" class="<?php print "$redhighlighted2"; ?>" title="Email required" value="<?php if(isset($_POST['EMAIL'])) echo $_POST['EMAIL']; ?>" size="34" />
</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;">xxxxxxxxx@anysite.com</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;"><?php print $errormsg; ?></div>
<div class="rowfloats">
	<label class="entryWidth" for="AREACODE">Phone</label>
	<input type=text name="AREACODE" size="3" maxlength="3" value="<?php if(isset($_POST['AREACODE'])) echo $_POST['AREACODE']; ?>"  onKeyUp="return autoTab(this, 3, event);" /> - <input type=text name="PHONE" size="3" maxlength="3" onKeyUp="return autoTab(this, 3, event);" value="<?php if(isset($_POST['PHONE'])) echo $_POST['PHONE']; ?>" />  <input type=text name="PHONE2" size="4" maxlength="4" onKeyUp="return autoTab(this, 4, event);" value="<?php if(isset($_POST['PHONE2'])) echo $_POST['PHONE2']; ?>" />
</div>
<div style="width:70%; height:12px; float:left; font-family:Arial, Helvetica, sans-serif; font-size:11px; padding:0px 0px 6px 88px; font-weight:bold;">(xxx) xxx-xxxx</div>
<div class="rowfloats requiredrow">
	<label  class="entryWidth requiredBold " for="COMMENTS">Message*</label>
	<textarea id="COMMENTS" name="COMMENTS" cols="36" rows="8" title="Message required"class="<?php print "$redhighlighted3"; ?>"><?php if(isset($_POST['COMMENTS'])) echo $_POST['COMMENTS']; ?></textarea>
</div>

<div class="rowfloats">
<?php


echo recaptcha_get_html($publickey, $error);
?>

</div>

<div class="rowfloats"><div class="rowAutoCentered">
<input name="submitted" type="submit" value="Submit" class="submit" />

</div></div>
</form>

Open in new window

0
 
dactechsConnect With a Mentor Commented:
In response to the question about a recaptcha variable, this should do it:

if($redhighlighted1 == "" && $redhighlighted2 == "" && $redhighlighted3 == "" && $resp->is_valid )
0
 
RobWellsMcAuthor Commented:
Perfect, your last solution worked - it was the answer to my vexing issue!     Before I award you 500 points and a big thank you, would you like me to make this private or public or does either not matter to you?
0
 
dactechsCommented:
It doesn't matter to me. I didn't know there was an option.
0
 
RobWellsMcAuthor Commented:
Okay - I'll just keep this private since I put a lot of time and hard work into my website portfolio, etc.   This will be on our history list on Experts Exchange from which we (I) can refer to often.  Tremendous thanks for your expert help and assistance!   Appreciate it.....
0
 
RobWellsMcAuthor Commented:
Have a better idea now how PHP If-Else conditional statements work.  This was a good lesson.  You'll make a real good teacher if you're not one alrady.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.