私はphpとmysqlが初めてです。次のコードはログインページからのものです。users と呼ばれる mysql データベースで boolean(tinyint) 値を使用しようとしています。フィールド 'paid' の値が 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.
}