I’m pretty sure everything is correct…I can post the two scripts here for double checking but I believe everything is correct and I have 255 varchar for password field in database.
login.php
[php]<?php
error_reporting (E_ALL ^ E_NOTICE);
session_start();
$user = $_POST[‘username’];
$pass = $_POST[‘password’];
mysql_connect(“127.0.0.1”,“root”,"");
mysql_select_db(“member”);
$user = mysql_real_escape_string($_POST[‘username’]);
$pass = mysql_real_escape_string($_POST[‘password’]);
if($_POST[‘Submit’]){
$select = “SELECT * FROM USERS where username=’”.$user."’ AND password=’".md5($pass)."’";
$msq = mysql_query($select);
if($msq == false){
echo mysql_error();
}
if(mysql_num_rows($msq)>0) {
$row = mysql_fetch_array($msq);
$username = $row[‘users’];
$_SESSION[‘username’] = $username;
echo $_SESSION[‘username’];
header(“location: checkuser.php”);
}
}
?>
Sign In here!!
Username:
Password:
[/php]
checkuser.php
[php]<?php
error_reporting (E_ALL ^ E_NOTICE);
?>
<?php
session_start();
//connect to db
$connect = mysql_connect("127.0.0.1","root","");
mysql_select_db("member");
$get = mysql_query("SELECT * FROM users WHERE username ='".$_SESSION['username']."'") or die(mysql_error());
while($row = mysql_fetch_array($get))
{
$admin = $row['user_level'];
if ($admin == 0)
{
header("Location: user-area.php");
}
elseif ($admin == 1)
{
header("Location: admin-page.php");
}
else
{
echo "this is invalid status";
}
}
?>[/php]