I wrote a page 'captcha.php' to generate a math captcha and send the result through session to the page which request it.
In captcha.php:
$_SESSION['captcha'] = $var;//$var is the calculate result
In index.php:
<img src="/captcha.php"/><input id="captchaa" type="text" name="a"/>
...
<?php
if($_POST['a']==$_SESSION['captcha'])
...
But I got 'Undefined index: captcha' error.
Any hint? Or what else more information do you need?
UPDATE: these lines are in both files if(!isset($_SESSION)) { session_start(); }
UPDATE:
I think i found the reason. My index.php is in the frame of Yii, and it has a session with id, but the captcha.php is not within the framework, so they cannot share a session.I tried to make it a view(/validation/captcha ),but it won't generate image properly that way, don't know why.
Now the problem is how to use Yii's session in captcha.php.