Feb 25, 2009 22:52
Ignore the (egregious) logic errors, just look at the code itself.
$HCUNnP = "Student 30203020";
$USub = $_GET["Uname"];
$PSub = $_GET["pword"];
$Val = "Hello Student";
$Den = "Username or Password are INCORRECT! Please Try Again!";
$Res = "Sundown you better take care If I find you been creepin round my back stairs";
$UnPSub = $USub." ".$PSub;
if (isset($UnPSub))
{
if ($UnPSub == $HCUNnP)
echo $Val;
else
echo $Den;
}
else
echo $Res;
Now,
Consider the same code, with all the variable names changed.
$UserName_Password = "Student 30203020";
$SubmittedUserName = $_GET["Uname"];
$SubmittedPassword = $_GET["pword"];
$Validation = "Hello Student";
$Denial = "Username or Password are INCORRECT! Please Try Again!";
$Restricted = "Sundown you better take care If I find you been creepin round my back stairs";
$temp = $SubmittedUserName." ".$SubmittedPassword;
if (isset($temp))
{
if ($temp == $UserName_Password)
echo $Validation;
else
echo $Denial;
}
else
echo $Restricted;
Do you see the difference?
I'll grant that $temp could be better, but I really don't want to call it what it is, as it would make me cry. The first was submitted by a 3rd year student.
Note: To bet entirely fair, they weren't taught PHP. They just had it thrown at them and told to mock up a password authentication page.
badcode