Andrew777 Posted March 27, 2013 Share Posted March 27, 2013 (edited) 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 March 27, 2013 by Andrew777 Quote Link to comment https://forums.phpfreaks.com/topic/276200-carrying-form-variables-to-captcha-page-not-working/ Share on other sites More sharing options...
Andrew777 Posted March 27, 2013 Author Share Posted March 27, 2013 (edited) Thought my code didn't get posted in the first message, but basically how do you keep your form variables from disappearing when the user doesn't answer captcha correctly??? Thanks for any help! Edited March 27, 2013 by Andrew777 Quote Link to comment https://forums.phpfreaks.com/topic/276200-carrying-form-variables-to-captcha-page-not-working/#findComment-1421286 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.