ConfusedOfLife
11-12-2002, 11:02 PM
In my dummy page I wana redirect the user to Congra.html if he answers me correctly, I write :
header("Location : Congra.html");
and I'm also totally aware that I have to write it b4 any html or
php directive that sends the header, or my header would be ignored ( and I remember that I got
some few error messages too when I tried to resend the header after it's already sent! ).
As usual the problem is that it doesn't work! If you wana see the whole code it's as follows
( it's a guess machine! )
<?PHP
$_POST['GuessNo'] = ( isset($_POST['GuessNo']) ) ? ( (int)$_POST['GuessNo'] + 1 ) : ( 0 );
if ( isset($_POST['entGuess']) )
if ( $_POST['entGuess'] > $_POST['toBGuessed'] )
$message = "High Expectations!";
elseif ( $_POST['entGuess'] < $_POST['toBGuessed'] )
$message = "Low Expectations!";
else
{
header("Location : Congra.html");
exit;
}
?>
<script language="javascript">
flag = 0;
function cheat()
{
if ( flag == 0 )
{
setTimeout("cheat();", 1000);
flag++;
}
else if ( flag == 1 )
{
window.status = randNum;
flag++;
setTimeout("cheat();", 1000);
}
else
window.status = "";
}
function randIt()
{
randNum = Math.floor( Math.random() * 100 + 1 );
document.forms[0].toBGuessed.value = randNum;
cheat();
}
</script>
<html>
<body onload="document.forms[0].entGuess.focus(); randIt();">
<center><h1>Guess Machine!</h1></center>
<br />
<h3><?=$message?></h3>
<form action="<? echo $_SERVER[PHP_SELF];?>" method="POST">
<input type="hidden" name="toBGuessed">
<br />
<table border=0>
<tr>
<td>
Guess #
</td>
<td>
<input type="text" name="GuessNo" value="<?=$_POST['GuessNo']?>">
</td>
</tr>
<tr>
<td>
Enter your guess in here :
</td>
<td>
<input type="Text" name="entGuess" value="<?=$_POST['entGuess']?>">
</td>
</tr>
<tr>
<td colspan="2">
<input type="Submit" value="Yallah!">
</td>
</tr>
</table>
</form>
</body>
</html>
header("Location : Congra.html");
and I'm also totally aware that I have to write it b4 any html or
php directive that sends the header, or my header would be ignored ( and I remember that I got
some few error messages too when I tried to resend the header after it's already sent! ).
As usual the problem is that it doesn't work! If you wana see the whole code it's as follows
( it's a guess machine! )
<?PHP
$_POST['GuessNo'] = ( isset($_POST['GuessNo']) ) ? ( (int)$_POST['GuessNo'] + 1 ) : ( 0 );
if ( isset($_POST['entGuess']) )
if ( $_POST['entGuess'] > $_POST['toBGuessed'] )
$message = "High Expectations!";
elseif ( $_POST['entGuess'] < $_POST['toBGuessed'] )
$message = "Low Expectations!";
else
{
header("Location : Congra.html");
exit;
}
?>
<script language="javascript">
flag = 0;
function cheat()
{
if ( flag == 0 )
{
setTimeout("cheat();", 1000);
flag++;
}
else if ( flag == 1 )
{
window.status = randNum;
flag++;
setTimeout("cheat();", 1000);
}
else
window.status = "";
}
function randIt()
{
randNum = Math.floor( Math.random() * 100 + 1 );
document.forms[0].toBGuessed.value = randNum;
cheat();
}
</script>
<html>
<body onload="document.forms[0].entGuess.focus(); randIt();">
<center><h1>Guess Machine!</h1></center>
<br />
<h3><?=$message?></h3>
<form action="<? echo $_SERVER[PHP_SELF];?>" method="POST">
<input type="hidden" name="toBGuessed">
<br />
<table border=0>
<tr>
<td>
Guess #
</td>
<td>
<input type="text" name="GuessNo" value="<?=$_POST['GuessNo']?>">
</td>
</tr>
<tr>
<td>
Enter your guess in here :
</td>
<td>
<input type="Text" name="entGuess" value="<?=$_POST['entGuess']?>">
</td>
</tr>
<tr>
<td colspan="2">
<input type="Submit" value="Yallah!">
</td>
</tr>
</table>
</form>
</body>
</html>