所以我想建立一个社交网络并关注一些来自 codeetastic 的 youtube 视频,但在第四部电影中,我的登录功能没有正确反应。你们有什么想法吗?(索引.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>
(登录.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());
?>
顺便说一句,我正在使用带有 php 5.4.15 和 mysql 的 xampp(不是 mysql* i *)