我将如何进行这项工作,我之前问过但没有得到正确的答案。这段代码是用户登录,所以当他们登录时,我希望用户名和头像可以通过站点进行跟踪。到目前为止,我只有用户名。我尝试过方法,但每次都失败了。
$username = $_POST['username'];
$password = sha1($_POST['password']);
$sql = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
$result = mysqli_query($conn, $sql) or die('Error querying database.');
$count=mysqli_num_rows($result);
if ($count == 1)
{
$row = mysqli_fetch_array($result);
while ($_SESSION['username'] = $row['username'])
{
session_start();
header('Location: index.php');
}
}
else
{
echo 'Invalid Logins';
}
mysqli_close($conn);
?>