主机:localhost用户名:xauth密码:xauthpassword数据库:xauth
删除xauth数据库中session表中的第一列accountid为$id的呢一行。
之前的代码是这样的
<?php
$username = $_GET["username"];
$password = $_GET["password"];
date_default_timezone_set('Asia/Shanghai');
$con = mysql_connect('localhost', 'xauth', 'xauthpassword') or die(mysql_error());
mysql_query('set names utf8', $con);
mysql_query('use xauth', $con) or die(mysql_error());
$sql = 'select * from accounts where playername="' . $username . '"';
$res = mysql_query($sql, $con);
$row = mysql_fetch_assoc($res);
if (empty($row)) {
echo "not exist";
exit();
}
if ($row['realpw'] != $password) {
echo "password wrong";
exit();
}
$id = $row['id'];
$sql2 = 'select * from sessions where accountid=' . $id;
$res2 = mysql_query($sql2, $con);
$row2 = mysql_fetch_assoc($res2);
if (empty($row2)) {
=====要放在这,不管有没有都尝试删除accountid为$id的一行======
mysql_query('insert into sessions values ("' . $id . '","' . $_SERVER['REMOTE_ADDR'] . '","' . date('Y-m-d H:i:s') . '")');
} else {
mysql_query('update sessions set ipaddress="' . $_SERVER['REMOTE_ADDR'] . '", logintime=' . date('Y-m-d H:i:s') . '" where accountid=' . $id);
}
echo "success!";
?>