Hi,
I’ve created cms with login page everything was all right when I test it in Apache but after I upload everything to my server for some unknown reason it won’t let me to log in
here are the page
Login Page
<html>
<head>
<title>CCC [Login]</title>
<style type = “text/css”>@import url(c/tips.css);</style>
</head>
<body>
<?php
if(@$_SESSION[‘auth’] == 0){
echo ‘<form action = “login.php” method = “post”>’;
echo ‘username: <input type = “text” name = “n” size = “15” />’;
echo ‘password: <input type = “password” name = “p” size = “15” />’;
echo ‘<input type = “submit” value=“login” /></form>’;
}else{
echo ‘::’. $_SESSION[‘name’] . ‘:: <a href=“logout.php”>Logout</a>’;
}
?>
</body>
</html>
Login Function
<?php
include_once(‘lib/db_fns.php’);
$name = $_POST[‘n’];
//echo $name;
$pass = $_POST[‘p’];
//echo $pass;
$conn = dbConnect();
$sql = "SELECT * FROM users WHERE name = '$name' AND password = PASSWORD('$pass')";
//echo $sql;
$result = mysql_query($sql);
//echo $result;
if(!$result || mysql_num_rows($result)<1){
echo "Please try again";
exit;
}
$row = mysql_fetch_array($result);
session_start();
$_SESSION['auth']=$row['permissions'];
//echo $_SESSION['auth']=$row['permissions'];
$_SESSION['name']=$row['name'];
echo $_SESSION['name']=$row['name'];
$_SESSION['id']=$row['id'];
//echo $_SESSION['id']=$row['id'];
$_SESSION['id']=$row['id'];
//echo $_SESSION['id']=$row['id'];
header('location:tips.php');
?>
Database Function Page
<?php
function dbConnect()
{
$results = @mysql_connect(‘dbname’, ‘username’, ‘password’);
if (!$results)
return false;
if (!@mysql_select_db(‘CCC’))
return false;
return $results;
}
?>
Session start Page
<?php
session_start();
function guard($level=1){
if(@$_SESSION['auth'] <$level){//not logged in
header('location:login_page.php');
exit;
}
}
?>
if anyone ever have the same problem as me please tell me how you solve it cos I’ve tried everything but it still doesn’t work