BTC USD 76,497.4 Gold USD 4,366.80
Time now: Jun 1, 12:00 AM

login php (solve)

<?php
require_once 'database.php';

session_start();

function signIn()
{
$password = md5(trim($_POST['password']));
$sql = 'SELECT username, user_type FROM users WHERE username = "'.addslashes($_POST['username']).'" ';
$sql .= 'AND password = "'.$password.'";';
dbConnect();
$result = runQuery($sql);

if (mysql_num_rows($result) != 0)
{
$data = mysql_fetch_assoc($result);
$_SESSION['username'] = stripslashes($data['username']);
$_SESSION['user_type'] = $data['user_type'];


if ($_SESSION['user_type'] == 'student')
{
header('Location: studentpage.php');
}
else if ($_SESSION['user_type'] == 'staff')
{
header('Location: adminpage.php');
}
}
else {
header('Location: login.php?status=SIGN-IN-FAILED');

}
}

function signOut()
{
session_destroy();
header('Location: index2.php');
}

function isSessionValid()
{
if (!isset($_SESSION['user_id']) || empty($_SESSION['user_id'])) {
signOut();
}

return true;
}

if(isset($_POST)){
signIn();
}


if (isset($_GET) && $_GET['logout'] == 'true') {
signOut();
}
?>

problem solved... password xencrypt masa check user time proses login..
 
terima kasih cik mesir duitraya hyppo dan niurexx untuk setelkan prob ni

terima kasih sekali lagi :)
 
problem solved... password xencrypt masa check user time proses login..

Bila tgk screen database yg tt post tu dah tau dah xencrypt.. Kalau tt tak tunjuk database tu sampai sudah laa.. :D
 
Bila tgk screen database yg tt post tu dah tau dah xencrypt.. Kalau tt tak tunjuk database tu sampai sudah laa.. :D

yup..huhu

ni skang nak buat search function,add function
 
Back
Top
Log in Register