hello. i was thinking of adding the random question script to my website's registration page as found in the search function of this forum.
however i noticed something amiss. whenever i view the source code, the random question in the source code is different from the one displayed in the browser. i have tried it on my website and it has the same problem. is it something to do with the sequence the server loads php scripts? however for my script my answer is always wrong. here is a sample of my script. i've shorten my registration form. $registrationformpart is just the front part of the registration form i have snipped off.
*edit*im using chrome browser. somehow IE doesnt have the inconsistency in the source code*edit*
<body>
<?php
$randomnumber = rand(1,4);
$question1 = <<< QUESTION1
<tr>
<td class="style1" colspan="2">What letter comes after B? (For Security Purposes)</td>
</tr>
<tr>
<td class="style1" colspan="2"><input type="text" name="securityquestion" maxlength="5" size="35" style="border:#B0A860 solid thin"></td>
</tr>
<tr><th colspan=2 align="center"><input type="submit" name="register" value="Register"></th></tr> </table>
</form>
QUESTION1;
$question2 = <<< QUESTION2
<tr>
<td class="style1" colspan="2">What letter comes after C? (For Security Purposes)</td>
</tr>
<tr>
<td class="style1" colspan="2"><input type="text" name="securityquestion" maxlength="5" size="35" style="border:#B0A860 solid thin"></td>
</tr>
<tr><th colspan=2 align="center"><input type="submit" name="register" value="Register"></th></tr> </table>
</form>
QUESTION2;
if ($randomnumber == 1 || $randomnumber == 2)
{$registrationform = $registrationformpart.$question1;
$securityanswer = 'c';}
if ($randomnumber == 3 || $randomnumber == 4)
{$registrationform = $registrationformpart.$question2;
$securityanswer = 'd';}
if (isset($_POST['register']))
{$securityquestion = strtolower(mysql_real_escape_string($_POST['securityquestion']));
if ($securityanswer!=$securityquestion)
{$registration = '<span class="style4">Your answer to the security question was incorrect. </span>';
$registration = $registration.$registrationform;}
}
else {$registration = $registrationform;}
echo $registration; ?>
</body>
thank you for your time.
however i noticed something amiss. whenever i view the source code, the random question in the source code is different from the one displayed in the browser. i have tried it on my website and it has the same problem. is it something to do with the sequence the server loads php scripts? however for my script my answer is always wrong. here is a sample of my script. i've shorten my registration form. $registrationformpart is just the front part of the registration form i have snipped off.
*edit*im using chrome browser. somehow IE doesnt have the inconsistency in the source code*edit*
<body>
<?php
$randomnumber = rand(1,4);
$question1 = <<< QUESTION1
<tr>
<td class="style1" colspan="2">What letter comes after B? (For Security Purposes)</td>
</tr>
<tr>
<td class="style1" colspan="2"><input type="text" name="securityquestion" maxlength="5" size="35" style="border:#B0A860 solid thin"></td>
</tr>
<tr><th colspan=2 align="center"><input type="submit" name="register" value="Register"></th></tr> </table>
</form>
QUESTION1;
$question2 = <<< QUESTION2
<tr>
<td class="style1" colspan="2">What letter comes after C? (For Security Purposes)</td>
</tr>
<tr>
<td class="style1" colspan="2"><input type="text" name="securityquestion" maxlength="5" size="35" style="border:#B0A860 solid thin"></td>
</tr>
<tr><th colspan=2 align="center"><input type="submit" name="register" value="Register"></th></tr> </table>
</form>
QUESTION2;
if ($randomnumber == 1 || $randomnumber == 2)
{$registrationform = $registrationformpart.$question1;
$securityanswer = 'c';}
if ($randomnumber == 3 || $randomnumber == 4)
{$registrationform = $registrationformpart.$question2;
$securityanswer = 'd';}
if (isset($_POST['register']))
{$securityquestion = strtolower(mysql_real_escape_string($_POST['securityquestion']));
if ($securityanswer!=$securityquestion)
{$registration = '<span class="style4">Your answer to the security question was incorrect. </span>';
$registration = $registration.$registrationform;}
}
else {$registration = $registrationform;}
echo $registration; ?>
</body>
thank you for your time.
Last edited: