I’ve made a login page and when the user logs in it should redirect. the page is [URL=”http://www.roondogid.co.uk/fm/login.php”]here
here is the code
[code=php]
<?php
$page_title = ‘Login’;
include (‘./header.html’);
if (isset($POST[‘submitted’])) {
require_once (‘./mysql_connect.php’);
if (!empty($_POST[‘gamertag’])) {
$g = escape_data($_POST[‘gamertag’]);
}else{
echo “<p class=’error’>You Forgot to enter your Gamertag!</p>”;
$g = FALSE;
}
if (!empty($_POST[‘pass’])) {
$p = escape_data($_POST[‘pass’]);
}else{
echo “<p class=’error’>You Forgot to enter your Password!</p>”;
$p = FALSE;
}
if ($g && $p) {
$query = “SELECT user_id, first_name FROM users WHERE (gamertag=’$g’ AND pass=SHA(‘$p’)) AND active IS NULL”;
$result = mysql_query ($query) or trigger_error(“Query: $queryn<br />MySQL Error: ” . mysql_error());
if (@mysql_num_rows($result) == 1) {
$row = mysql_fetch_array ($result, MYSQL_NUM);
mysql_free_result($result);
mysql_close();
$_SESSION[‘first_name’] = $row[1];
$_SESSION[‘user_id’] = $row[0];
$url = ‘http://’ . $_SERVER[‘HTTP_HOST’] . dirname($_SERVER[‘PHP_SELF’]);
if ((substr($url, -1) == ‘/’) OR (substr($url, -1) == ‘\’) ) {
$url = sustr ($url, 0 ,-1);
}
$url .= ‘/index.php’;
ob_end_clean();
header(“Location: $url”);
exit();
}else{
echo “<p class=’error’>Either the Gamertag and password entered do not match those on file or you have not activated your account.</p>”;
}
}else{
echo “<p class=’error’>Please try again</p>”;
}
mysql_close();
}
?>
<h1>Login</h1>
<form action=”login.php” method=”post”>
<fieldset>
<p>Gamertag: <input type=”text” name=”gamertag” size=”20″ maxlength=”20″ value=”<?php if (isset($_POST[‘gamertag’])) echo $_POST[‘gamertag’]; ?>” /></p>
<p>Password: <input type=”password” name=”pass” size=”20″ maxlength=”20″ /></p>
<div align=”center”><input type=”submit” name=”submit” value=”Login” /></div>
<input type=”hidden” name=”submitted” value=”TRUE” />
</fieldset>
</form>
<?php
include (‘./footer.html’);
?>