私はここで間違っていますか?それは理由を与えずにDatabase Count Failed(Process.phpの$ count行にある)です。私は私達のそのラインの一部を「か死ぬか」を取るとき、それは常に私が押され、それが実際にアカウントを作成していないボタンに関係なく、「作成したユーザーアカウント」が表示さ...ログインPHPエラー
Form.php
<html>
<head>
<title>Forms</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
</head>
<body>
<form action="process.php" method="post">
<label for="username">Email: </label>
<input type="email" name="username" value="" id="username"/>
<br/>
<label for="password">Password: </label>
<input type="password" name="password" value="" id="password"/>
<br/>
<input type="submit" name="submit" value="Sign in"/>
<input type="submit" name="submit" value="Sign up"/>
</form>
</body>
</html>
Process.php
<?php
//1. Create a database connection
$connection = mysql_connect("localhost","web","1234") or die("Database connection failed: " . mysql_error());
//2. Select a database to use
$db_select = mysql_select_db("tongue", $connection) or die("Database selection failed: " .mysql_error());
?>
<html>
<head>
<title>Form processing</title>
<link rel="stylesheet" href="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.css" />
<script src="http://code.jquery.com/jquery-1.7.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.1.0-rc.1/jquery.mobile-1.1.0-rc.1.min.js"></script>
</head>
<body>
<?php
$username = $_POST['username'];
$password = trim($_POST['password']);
$hashed_password = sha1($password);
$action = $_POST['submit'];
//3. Select email, password from database
$query = "
SELECT email, password FROM user
WHERE email='$username' AND password='$hashed_password'";
$user = mysql_query($query, $connection)
or die ("Database query failed: ".mysql_error());
$count = mysql_num_rows($user) or die ("Database count failed: ".mysql_error());
//4. Authenticate user
if ($count == 1) {
if($action="Sign up"){
echo "User already exists";
} else if ($action="Sign in"){
echo "User signed in";
};
} else if ($count == 0){
if($action="Sign up"){
$query = "
INSERT INTO users (email, password)
VALUES ('$username', '$hashed_password')";
$signup = mysql_query($query, $connection);
echo "User account created";
} else if ($action ="Sign in"){
echo "Username and/or password incorrect";
};
};
?>
</body>
</html>
)はポイント(あなたのコードのダイを持つがありません、あなたが処理するために行く合法的な状態であり、 $ countが0の場合、そこにありますか? –