所以我想创建一个社交网络并从codeetastic跟踪一些youtube视频,但在第四部电影中,我的登录功能没有做出正确的反应。你们有什么想法吗? (的index.php)
<?php include "templates/nav.php"; ?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8"/>
<title>EverTime</title>
<link rel="stylesheet" href="css/main.css"/>
<script src="js/main.js"></script>
</head>
<body>
<div id="middle">
<h1 id="welcome">Welcome to EverTime!</h1>
<form action="parse/login.php" method="post">
<input type="text" name="username" id="username" placeholder="Username..."/>
<input type="password" name="password" id="password" placeholder="Password..."/>
<input type="submit" name="submit" id="submit" value="Log in"/><a id="link" href="register.php">Create an account</a>
</form>
</div>
</body>
</html>
(login.php中)
<?php
//connect
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("evertime") or die(mysql_error());
//login script
if(isset($_POST['username'])) {
$username = $_POST['username'];
$password = $_POST['password'];
$md5pass = md5($password);
$query = mysql_query("SELECT * FROM `users` WHERE username='$username' AND password='$md5pass'");
$get = mysql_fetch_assoc($query);
if($get = ""){
echo "User does not exist";
} else {
echo "User does exist";
}
}
?>
(config.php中)
<?php
//connect to database
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("evertime") or die(mysql_error());
?>
顺便说一下,我正在使用xampp和php 5.4.15以及mysql(不是mysql * i *)
答案 0 :(得分:4)
if($get = ""){
应该是
if($get == ""){