我有这个代码在标题中提到的这个错误:
<?php session_start();
ob_start();
include("connection.php");
$username = $_POST['username'];
$password = $_POST['password'];
$query = mysql_query("SELECT * FROM users WHERE user_username = '$username' AND user_password = '$password'",$conn)
or die($query. "<br/><br/>".mysql_error());
if($query = mysql_affected_rows() > 0) {
$record = mysql_fetch_assoc($query);
$validuser = $row['username'];
$_SESSION['valid'] = $validuser;
if(isset($_SESSION['valid']))
{
header('Location: index.php');
}
} else { ?>
<script>alert('Username not registered.')
</script>
<?php
}
exit();
?>
这是我的网络作业,我是 php 的新手。请需要帮助。