PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function verifyCode() {
if(isset($_GET['user']))
$user = $_GET['user'];
else
$user = $_POST['postuser'];
$query = mysql_query("SELECT code, admin, id
FROM logins
WHERE username = '$user'");
if(mysql_num_rows($query) > 0) {
$code = mysql_result($query, 0, 0);
$uid = mysql_result($query, 0, 2);
$admin = mysql_result($query, 0, 1);
if($code == $_POST['code']) {
mysql_query("UPDATE logins
SET verified = 'Y'
WHERE username = '$user'");
$_SESSION['username'] = $user;
$_SESSION['uid'] = $uid;
if($admin == "Y") $_SESSION['admin'] = "Y";
echo "Code verified. <br><br>Click <a href = 'http://stesbox.co.uk/racetrack2'> Here </a> to continue <br>";
}
else
header("Location: http://stesbox.co.uk/racetrack2/index.php?page=verifyCode&user=$user");
}
else
echo "There was a problem processing your form. Please try again";
}
Cookies are turned on in my browser and when I try and load the page in IE the page never even gets there. I have sessions turned on at the beginning of my code. Can you see an error that may cause this?
I think I've created an infinite loop on the header function. Just checked my Apache logs and there's thousands of requests for the URL that isn't displaying properly.
I think I've created an infinite loop on the header function. Just checked my Apache logs and there's thousands of requests for the URL that isn't displaying properly.
Doh!
Yes, that's exactly what FireFox was trying to tell you. pickle's advice is good. There's hardly ever a time where you'll call header('Location: ... and not follow it with an exit()
I'd never thought about the dangers of not exiting after a header function. I suppose not thinking about it you assume as soon as the header function is hit nothing else is going to happen after that.
Thanks for the tip I shall keep that one well remembered.