0

The code is part of a captcha script.Take a look at how it works here http://www.web1marketing.com/resources/tools/quickcaptcha/ . Here is the code:

<?php

include "settings.php";

session_start();
$string = strtoupper($_SESSION['string']);
$userstring = strtoupper($_POST['userstring']); 
session_destroy();   

if (($string == $userstring) && (strlen($string) > 4)) {
    header("Location: $success");
    exit();
} else {
    header("Location: $failure");
    exit();
}
?> 

The error I am getting

Notice: Undefined index: string in /storage/ssd1/092/public_html/result.php on line 24

Warning: Cannot modify header information - headers already sent by (output started at /storage/ssd1/092/public_html/result.php:24) in /storage/ssd1/092/public_html/result.php on line 32

1 Answers1

0

The reason it is failing is because $string is not filled if no session is present.

When this happens, the notice: Undefined index pops up, which basically means, it expects a number, but an empty string was found instead.

You need to either check for the $string to contain something before blindly testing against it, or you need to assign it a value at the start of your script.

LPChip
  • 792
  • 1
  • 11
  • 25