Hey everybody
I have a php page with the following form on it:
PHP Code:
<form action="" method="post">
<input type="hidden" name="random" value="<?php echo $random; ?>" />
<table width="100%" border="0" cellspacing="0" cellpadding="0">
<tr>
<td align="center">
Code 1
<br />
<input name="code1" type="text" />
</td>
<td align="center">
Code 2
<br />
<input name="code2" type="text" />
</td>
<td align="center">
Code 3
<br />
<input name="code3" type="text" />
</td>
</tr>
<tr>
<td align="center">
Code 4
<br />
<input name="code4" type="text" />
</td>
<td align="center">
Code 5
<br />
<input name="code5" type="text" />
</td>
<td align="center">
Code 6
<br />
<input name="code6" type="text" />
</td>
</tr>
<tr>
<td colspan="3" align="center">
<br />
<input type="submit" name="submit" value="Submit" />
<input type="reset" name="reset" id="reset" value="Reset" />
</td>
</tr>
</table>
</form>
In order to determine where the user goes when submitting the form, I have the following code at the top of the same page:
PHP Code:
$random = rand(150000, 950000);
session_start();
if(isset($_POST['submit']))
{
$strCode1 = $_POST['code1'];
$strCode2 = $_POST['code2'];
$strCode3 = $_POST['code3'];
$strCode4 = $_POST['code4'];
$strCode5 = $_POST['code5'];
$strCode6 = $_POST['code6'];
$code1 = strtolower($strCode1);
$code2 = strtolower($strCode2);
$code3 = strtolower($strCode3);
$code4 = strtolower($strCode4);
$code5 = strtolower($strCode5);
$code6 = strtolower($strCode6);
if ( $code1 == "this" && $code2 == "code" && $code3 == "works" && $code4 == "really" && $code5 == "well" && $code6 == "yay" ) {
$_SESSION['confirmed'] = true;
header('Location: yay.php');
exit;
} else {
$_SESSION['confirmed'] = false;
header('Location: boo.php');
exit;
}
}
That works perfectly, as far as getting the user to the correct page, based on if they put in the correct code or not.
However, what I want to do, is access the number that is generated by this line:
PHP Code:
<input type="hidden" name="random" value="<?php echo $random; ?>" />
on either "yay.php" or "boo.php".
I've tried $_GET and $_POST when trying to access it on those pages, but can't seem to get it right.
Any ideas or suggestions are greatly appreciated
