1

我是 php 和 mysql 的新手。以下代码来自登录页面。我正在尝试在名为 users 的 mysql 数据库中使用 boolean(tinyint) 值。如果“付费”字段的值为 0,我想将用户发送到我的 pay.php 页面,如果值为 1 并且登录详细信息正确,我想将用户发送到 index.php。然而,无论数据库中的值是 0 还是 1,代码都会将用户发送到 pay.php。任何帮助将不胜感激!

$query = mysql_query("SELECT * FROM `users` WHERE username = '$username' AND password = '$password'") or die (mysql_error()); // mySQL query

$r = mysql_num_rows($q); // Checks to see if anything is in the db.
$row = mysql_fetch_array($query);
if($row['paid'] == 0);{     //NOT WORKING!!!    
    header ("location:pay.php");// go to pay.php
    exit( );// Stops the rest of the script.
}

if ($r == 1) { // There is something in the db. The username/password match up.
    $_SESSION['logged'] = 1; // Sets the session.
    header ("location:index.php");// go to index.php
}
else { // Invalid username/password.
    exit("Incorrect username/password!"); // Stops the script with an error message.        
}
4

1 回答 1

1
if($row['paid'] == 0);{

去掉那里的分号:

if($row['paid'] == 0){
于 2013-03-15T19:43:26.153 回答