好的,所以这是我的脚本尝试连接到 sqlserver 以使用以前存储在数据库中的凭据登录,但是当我尝试访问该页面时出现错误
“解析错误:语法错误,第 32 行 login.php 中的意外 T_ELSE”
我在各种网站上查找过,似乎无法找出这个脚本有什么问题
提前致谢。
<?php
session_start();
if(!isset($_SESSION["user_id"])){
header("location");
}
?>
<?php
$username = $_POST['txt_username'];
$password = $_POST['txt_password'];
if ($username&&$password){
$connect = mysql_connect("database", "username", "password") or die("No Server Found");
mysql_select_db("hnd_1213_marwick") or die("No Connection");
$query = mysql_query("SELECT * FROM account WHERE username='$username'");
$numrows = mysql_num_rows($query);
if($numrows !=0){
while ($rows = mysql_fetch_assoc($query)){
$dbusername = $row['username'];
$dbpassword = $row['password'];
}
if ($username==$dbusername&&$password==dbpassword){
echo "Login Successful. <a href='homepage.php'>Click Here to go to the home page</a>";
$_SESSION['username']=$dbusername;
else
echo "Incorrect Login";
else
die ("This account does not exsist");
}
else
die ("Please enter a username and password");
?>