mskhansari
New Member
سلام
من یه عضو جدید در این سایت هستم
یه اشکال کوچولو دارم
لطف کنید بی زحمت هر کی میتونه حلش کنه
به کدهای زیر یه نگاه بندازید
من یه عضو جدید در این سایت هستم
یه اشکال کوچولو دارم

لطف کنید بی زحمت هر کی میتونه حلش کنه
به کدهای زیر یه نگاه بندازید
login.php
---------------------------------------
main.php
f
PHP:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<title>login page</title>
</head>
<center>
<body>
<?php
include_once('db_funcs.php');
$username = $_REQUEST['loguser'];
$password = $_REQUEST['logpass'];
$con = db_connect();
$log = $con->query("select * from users where username = '$username' and password = '$password'");
if ($log->num_rows <> 1)
{
print 'username or password is not correct please try again';
print('<br>');
echo '<a href="index.php">try again</a>';
}
else
{
$_row = $log->fetch_assoc(); // etelaate shakhsi
session_start();
$_SESSION = $_row;
unset($_SESSION['password']);
header('location: main.php');
}
?>
</body>
</center>
</html>
main.php
PHP:
<?php
session_start();
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
</head>
<body>
<?php
echo '<pre>';
print_r($_SESSION);
echo '</pre>';
print '<br>';
print '<br>';
print '<pre> <a dir="ltr" href="logout.php">exit<a> </pre>';
print '<br>';
$eslah = $_SESSION['eslah'];
print($eslah);
if ($eslah = 'yes') // moshkel injast
{
print 'ok';
}
else
{
print 'not ok';
}
?>
</body>
<title>welcome<?php echo($_SESSION['name']); ?> </title>
</html>
اون شرط داخل main.php چه درست باشه و چه غلط هم عبارت داخل if رو اجرا میکنه هم عبارت داخل else رو
چرا؟
ممنون
چرا؟

ممنون
آخرین ویرایش: