I'm having a weird issue with 2 pages of mine, that employ somewhat of an improvised Captcha code validation.
The Captcha consists of only 5 different images, called captcha1.jpg to captcha5.jpg.
The second page in the sequence validates the captcha by using the following code:
if ($_SESSION['image'] = "captcha1.jpg") {
if ($_POST['captcha'] == "634K6") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
if ($_POST['captcha'] == "634k6") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
else {
header('Location: step1_captcha_redo.php');
die();
}
}
if ($_SESSION['image'] = "captcha2.jpg") {
if ($_POST['captcha'] == "4eT99") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
if ($_POST['captcha'] == "4et99") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
else {
header('Location: step1_captcha_redo.php');
die();
}
}
if ($_SESSION['image'] = "captcha3.jpg") {
if ($_POST['captcha'] == "AGA2P") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
if ($_POST['captcha'] == "aga2p") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
else {
header('Location: step1_captcha_redo.php');
die();
}
}
if ($_SESSION['image'] = "captcha4.jpg") {
if ($_POST['captcha'] == "hKYK8") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
if ($_POST['captcha'] == "hkyk8") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
else {
header('Location: step1_captcha_redo.php');
die();
}
}
if ($_SESSION['image'] = "captcha5.jpg") {
if ($_POST['captcha'] == "NG6j5") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
if ($_POST['captcha'] == "ng6j5") {
echo $contents;
mail($to,$subject,$msg,$from);
die();
}
else {
header('Location: step1_captcha_redo.php');
die();
}
}
$_SESSION['image'] is initialized on the first page, depending on the image that will be randomly selected - I've tested and echoed its contents multiple times, and it works just fine.
The problem I'm having here is that the only captcha code that is correctly validated, is captcha1.jpg ( the first IF statement in the list ). For some reason, all the other 4 are correctly defined, but always resolve to FALSE, even if the correct one is entered, and the ELSE statement is therefore executed.
What am I doing wrong here?
Aucun commentaire:
Enregistrer un commentaire