Jump to content

Recommended Posts

Login page:

 

<?php 
session_start();
require_once('../Connections/prbc.php');

if(isset($_POST['login'])){
$username = '';
$password = '';

if (isset ($_POST['username']) && $_POST['username'] != '')

$username = $_POST['username'];

if(isset ($_POST['password']) && $_POST['password'] != '')

$password = $_POST['password'];

$username = mysql_real_escape_string( $username );
$password = mysql_real_escape_string( $password );

$db_password = md5($password);

mysql_select_db('prbcweb') or die(mysql_error());
$login = mysql_query("SELECT * FROM prbc_user WHERE `user_name` = '$username' AND `user_pass` = '$db_password'");
$row_login = mysql_fetch_array($login);
$row_login_total = mysql_num_rows($login);

if ($row_login_total == 1) {
$_SESSION['MM_Username'] = $row_login['user_name'];
$_SESSION['UID'] = $row_login['user_id'];
$_SESSION['auth_level'] = $row_login['user_access_level'];
echo "<script type=text/javascript>location.href='approver.php'</script>";

} elseif ($row_login_total <> 1) {
header("Location: login_2.php");
}
}
?> 

 

Access Control on Pages:

 

<?php 
session_start();
if (isset($_SESSION['MM_Username']) && ($_SESSION['auth_level'] <= '5')) {
  $username = $_SESSION['MM_Username'];
}
else {
echo "<script type=text/javascript>location.href='login_2.php'</script>";
}

Yea.. Once you are 'logged' in the login script, set a cookie, then when you check with this:

 

if (isset($_SESSION['MM_Username']) && ($_SESSION['auth_level'] <= '5')) {

  $username = $_SESSION['MM_Username'];

}

 

you can also do && $_COOKIE['user_logged'] = "yes")

 

just a thought.. might be pointless but i like to use cookies & sessions..

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.