captcha page checking
Posted: Mon Jan 25, 2010 6:53 am
Hello,
I have a PHP page, which has captcha.php page called in for CAPTCHA. Now this captcha.php page has code
like
now i am checking the captcha value in another page "sample_inc.php" which is included in the main page "main.php"
as
now if I open the page "main.php" in two or more different tabs in the IE browser. The captcha field will take the recent value i.e in $_SESSION['total'], irrespective of the sum of two numbers , otherwise it gives an error shown above.
How should I re-structure my code so that even If I open the same page in two different tabs of the browser, CAPTCHA will be unique and not interfere with the value of other tab.
Thank you
I have a PHP page, which has captcha.php page called in for CAPTCHA. Now this captcha.php page has code
like
Code: Select all
@session_start();
$num = array(1,2,3,4,5,6,7,8,9);
$words = array("1","2","3","4","5","6","7","8","9");
$plus = "+";
mt_srand((double)microtime()*1000000);
$first = mt_rand(0,8);
$second = mt_rand(0,8);
$total = $num[$first] + $num[$second];
$showcode = $words[$first] . " + " . $words[$second] . "";
$_SESSION['total'] = $total;now i am checking the captcha value in another page "sample_inc.php" which is included in the main page "main.php"
as
Code: Select all
if ($_SESSION["total"]!= $_POST["total"])
{
$errors[]="You entered the wrong answer for the sum of two digits.";
}How should I re-structure my code so that even If I open the same page in two different tabs of the browser, CAPTCHA will be unique and not interfere with the value of other tab.
Thank you