Understanding session varables
Posted: Tue Mar 14, 2006 1:14 pm
I have added a security image to my guestbook. Someone has been using spoofed ip address to abuse our book. I have installed the GD library, and have been successful with the image dispay. However when i test echo the generated code i get and empty varable. Here is the code i have so far.
Below is the code that calls the include, and is suposed to generate
Below is the code to valadate that the session code = the inputed code
However my session code varable is blank.
My online version of the code can be found at http://www.delmarvanightlife.com/module ... dentry.php
Below is the code that calls the include, and is suposed to generate
Code: Select all
<?php
// include security image class
require('includes/security-image.inc.php');
// start PHP session
session_start();
// get parameters
isset($_GET['width']) ? $iWidth = (int)$_GET['width'] : $iWidth = 150;
isset($_GET['height']) ? $iHeight = (int)$_GET['height'] : $iHeight = 30;
// create new image
$oSecurityImage = new SecurityImage($iWidth, $iHeight);
if ($oSecurityImage->Create()) {
// assign corresponding code to session variable
// for checking against user entered value
$_SESSION['code'] = $oSecurityImage->GetCode();
} else {
echo 'Image GIF library is not installed.';
}
?>Code: Select all
else if (isset($_POST['submit']))
{
if (strtoupper($_POST['code2']) == $_SESSION['code'])
{
echo 'Congratulations, you entered the correct code.';
print "Thanks for posting, you will now be redirected <META HTTP-EQUIV = 'Refresh' Content = '2; URL =http://www.delmarvanightlife.com/modules.php?name=gbook'> ";
}
else
{
echo $code2;
echo $code;
echo 'You have entered the wrong code. Please <a href="/modules.php?name=gbook&file=addentry">try again</a>.';
}
}
}
?>My online version of the code can be found at http://www.delmarvanightlife.com/module ... dentry.php