It's my first time posting here as it's also the first time I've decided to build a site from scratch for myself. I'm creating a contact page with a basic captcha script. For reasons you might think are crazy, I want to display the captcha as text. I decided against png as the (anti)aliasing was pretty bad with a transparent background and I don't think my site is going to cause too much unwanted attention yet.
Here is my captcha.php
<?php
session_start();
$characters_on_image = 4;
$possible_letters = '0123456789';
$code = '';
$i = 0;
while ($i < $characters_on_image) {
$code .= substr($possible_letters, mt_rand(0, strlen($possible_letters)-1), 1);
$i++;
}
echo $code;
header('Content-Type: text/plain');
$_SESSION['code'] = $code;
?>
The problem I'm having is that if I use <?php print $_SESSION['code']; ?>
it will print the previous code. My programming is pretty ropey and I was wondering if there is a way to show the current generated code in a <label>
tag?