Jump to content

Carrying form variables to captcha page not working...


Andrew777

Recommended Posts

Hello,
I was hoping someone could give me some advice on how to fix this problem..
 
I am trying to implement PHP Securimage captcha on one of my sites.
 
The thing is I have a Form (Page 1) and I am trying to carry my form variables (several) to the Captcha page (Page 2).
And then when the user answers the captcha properly the php code on that page sends me the form data.
 
The Form works fine if I keep captcha on the same page (I know how to do that), but I have a reason to separate the two. And what happens is I think i can get the variables over to the next page, but if someone doesn't answer the Captcha properly and the page RELOADS to show the "wrong captcha" message, I lose my form variables from the previous page...
 
 
So Form Page -> Captcha Page -> Sends Email.
 
I lose the carried over variables when the wrong captcha is entered and the user has to redo the captcha.
 
Captcha page has the following setup just showing one variable for brevity sake...
 
Form Page:

<form method="post" action="contact-captcha.php">
<input name="fullname" id="fullname" size="30" maxlength="40">
<input type="submit" value="Submit Info">
</form>

 

Captcha (contact-captcha.php) Page:

<?php session_start();

$fullname=$_REQUEST['fullname'];

if(isset($_REQUEST['sub']))
{
    include_once $_SERVER['DOCUMENT_ROOT'] . '/securimage/securimage.php';
    $securimage = new Securimage();

    if ($securimage->check($_POST['captcha_code']) == false) {
          
        $fullname = $_SESSION['fullname'];

 $msg1="-> Sorry, Wrong Verification Code Entered";
        }
    
    else
    {
 
    $fullname = $_SESSION['fullname'];

$mailmsg = '<table width="500px" border="0" align="center" cellpadding="0" cellspacing="0">
<tr><td></td>'.$fullname.'</tr></table>'

etc....

    }
  }
?>

<body>
<form name="form1" method="post" action="" onSubmit="return validate(this);">
<?php    
if(isset($msg1)) { echo "<br /><br /><span class='error'>".$msg1."</span><br /><br />"; }
else { echo '<br /><br />';}
?>
<img id="captcha" src="http://www.mysite.com/securimage/securimage_show.php" 
alt="CAPTCHA Image" />
<a href="#" onclick="document.getElementById('captcha').src = '/securimage/securimage_show.php?' + Math.random(); return false"><img src="images/reload.png" border="0" /></a>
<br><br>
Enter code: <input class="fields" type="text" name="captcha_code" size="15" maxlength="6" />
<input name="sub" id="sub" type="submit" value="Submit Info">
</form>
</body>
Edited by Andrew777
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.