'Random Question' Script

tillabong

New Member
Messages
60
Reaction score
0
Points
0
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.
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
Chrome re-requests the page when you view the page source. You can use the Web Inspector to examine the structure of the rendered page you're viewing. If you need any more help than that, you need to provide a link to a live page.
 
Last edited:

misson

Community Paragon
Community Support
Messages
2,572
Reaction score
72
Points
48
There are a couple of related issues (#523 and #10570), though they aren't resolved. When you view the source of a page that was retrieved with POST, you'll get the source for the page as retrieved with a GET. If there's a cached copy of the page retrieved with GET, Chrome will use that version and won't re-request the page.

Tillabong, what version of Chrome are you using?
 
Last edited:

tillabong

New Member
Messages
60
Reaction score
0
Points
0
thanks for the reply. im using version 4.1.249.1045. i managed to solve the problem with the random question script though. thank you so much for your time.
 
Top