السلام عليكم
عملت صصفحه دخول وفيها قسم لدخول الادمن وقسم لليوزر بحيث ان admin عملت له قيمه 1 ويوزر 0 في sql database وكان يشتغل كويس
بعدين ضفت cookies واشتغل بس لما ضفت قسم ان المستخدم يقدر يعدل بياناته update your details
صار الادمن لما يدخل الموقع يدخل كانه user مو كانه admin مايروح لصفحه الادمن والكوكيز صار مايشتغل اختفى وتعديل المعلومات اشتغل كويس
هذا هو الكود ماعرف وين المشكله بالظبط
<?php
//******************************** Login page *************************************//
session_start(); //starting the session
//opens connection to mysql server
if(isset($_POST['loginbtn'])) {
//get data
$username = $_POST['username']; // set username
$salt = "ijrhfwe76546^%£%^&YGFC"; // encryption for the user password
$password = sha1(md5(sha1($_POST['password'].$salt))); // set password
// if username and password are typed into the form field then
if ($username && $password) {
mysql_connect ('localhost', '', '') or die ("Couldn't connect!"); // connect to database (hostname,username, password)
mysql_select_db ("login_user") or die ("Couldn't find the table you request"); // select table login_user from SQL dababase
$query = mysql_query ("SELECT * FROM users WHERE username = '$username' AND password = '$password'");
$num_rows = mysql_num_rows($query); // هذا الكود الي ضفته عشان اليوزر بامكانهم يعدلو معلوماتهم بواسطه id
$result = mysql_fetch_array($query);
$_SESSION['ID'] = $result[0]; // لين هنه الثلاثه الاسطر هذي ضفتها وخربت عليا cookies و admin
if ($num_rows != 0) { // number of rows are not equal to zero
$_SESSION['user'] = $username;
while ($row = mysql_fetch_assoc($query)) { //loop for each record
$admin = $row['admin'];
}
if ($admin == 1) { // if this user is admin, restore him/her in the session as admin
// admin
$_SESSION['admin'] = 1;
header( 'Location: adminpage.php' ); // redirect to admin page
} else {
// not admin
header( 'Location: customerpage.php' ); // redirect to customer page
}
if ($remeberuser =="on") //value return is on
setcookie("user", $username, time()+3600); //expire in one hour
} else
echo "<p> Incorrect username or password </p> "; //display an error message when user enter either wrong username or password
}
}
unset($_POST['user']);
?>