可能重复:
为什么我的 PHP 总是出现 500 错误?
我正在创建一个允许用户登录网站的页面。我不断收到 500 错误。这是给我一个错误的代码:
<?php
if(isset($_POST['submit']))
{
$username = $_POST['username'];
$password = $_POST['password'];
include( 'connection.php' );
if(empty($username) || empty($password))
{
$error = 'Please enter your username and password'
}
else
{
$password = md5($password);
$sql = mysql_query("SELECT * FROM users WHERE username = $username AND password = $password LIMIT 1") or die(mysql_error)();
$num_rows = mysql_num_rows($sql);
if($num_rows == 1)
{
$fetch = mysql_fetch_array($sql);
extract ($fetch);
echo $username;
}
else
{
echo 'There was an error while logging in'
}
}
?>