I have these two sessions vars on my php that generate a random number:
<?php
session_start();
if (!isset($_SESSION['num1']) && !isset($_SESSION['num2'])) {
$_SESSION['num1'] = rand(1,5);
$_SESSION['num2'] = rand(1,5);
}
?>
And on the same page I have this label that shows num1 + num2:
<label><?=$_SESSION['num1']?> + <?=$_SESSION['num2']?> ?</label>
What I would like to do is to turn the img that is right on the side of the label into a link, that will update num1 and num2 vars without refreshing the page, is it possible?
Should i create those vars in a separeted file like captcha.php, and then include it on the label showing the generated numbers with an echo on captcha.php or something like that? Or do I need to use ajax?
Can you guys give me a hand on this, i'm designer, trying to create a portfolio, and this form is driving me crazy! Thanks
@Koterpillar As you said, on my captcha.php i would have these:
<?php
session_start();
if (!isset($_SESSION['num1']) && !isset($_SESSION['num2'])) {
$_SESSION['num1'] = rand(1,5);
$_SESSION['num2'] = rand(1,5);
}
?>
Then i will include the captcha php into a div lets say #captcha. The captcha is done with a simple question like 1+3=, there is no drawing image or anything like that, its a small webpage, i think i wont need those noise and lines on the captcha, the validation is made on php submit form. but how to call the captcha php with ajax to update that div? Its something like this?
$("#captcha").click(function() {
$.ajax({
type: "POST",
url: "includes/captcha.php",
data: ,
success: function(){
},
});
}
Thanks for you help!!