我有这段代码,我正在尝试创建一个会话以获取用户的画廊 ID..
问题是,如果我使用 $_SESSION['username'] 它可以工作,但像这样不是......你能检查一下这有什么问题吗?
谢谢!
mysql_connect($host, $user, $pass);
mysql_select_db($database);
$username = mysql_real_escape_string($_POST['username']);
$password = md5($_POST['password']);
$result = mysql_query("SELECT * FROM $table WHERE username = '$username' AND password = '$password'
");
while ($rows = mysql_fetch_array($result)) {
if(mysql_num_rows($result))
{
$rows['gal_id']=$gal_id;
session_start();
$_SESSION['gal_id'] = htmlspecialchars($gal_id);
}
else
{
// Invalid username/password
echo '<p><strong>Error:</strong> Invalid username or password.</p>';
}