我想創建一個登錄功能與PHP。登錄功能與PHP的mysql錯誤
直到現在,這是我得到的。
<?php
include("dbconnection.php");
//select a database to work with
$mysqli->select_db("eamunter_opskrift");
Echo ("Selected the eamunter_opskrift database...<BR><BR>");
// get the username and password from the login form
$username=$_POST['username'];
$password=$_POST['password'];
//Protect username and password
$username = stripslashes($username);
$password = stripslashes($password);
$username = mysql_real_escape_string($username);
$password = mysql_real_escape_string($password);
$query ="SELECT * FROM brugerregistration WHERE username='$username' and password='$password'";
$result = $mysqli->query($query);
$count=mysqli_num_rows($result);
// If result matched $username and $password, the count of table rows should equal 1
if($count==1){
// Register session variables and redirect the user to "login_success.php" page
session_start();
$_SESSION['username']= $username;
header("location:login_success.php");
}
else {
echo "Wrong Username or Password";
}
?>
我不斷收到同樣的錯誤 我想不出是什麼問題...我dbconnection.php工作的其他任何地方。
Selected the eamunter_opskrift database...
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /home/www/.dk/reg/post_login.php on line 13
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: No such file or directory in /home/www/.dk/reg/post_login.php on line 13
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/www/.dk/reg/post_login.php on line 13
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: [2002] No such file or directory (trying to connect via unix:///tmp/mysql.sock) in /home/www/.dk/reg/post_login.php on line 14
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: No such file or directory in /home/www/.dk/reg/post_login.php on line 14
Warning: mysql_real_escape_string() [function.mysql-real-escape-string]: A link to the server could not be established in /home/www/.dk/reg/post_login.php on line 14
Wrong Username or Password
任何人都可以幫我嗎?
如果重要我也可以上傳表格,但並不認爲它很重要。
很感謝:-) 你知道爲什麼它會在鏈接末尾寫'post_login.php?username = user&password = 1234&Submit = Login'。鏈接中的密碼不是很聰明... –
可能是因爲您的'
在您的HTML表單中,添加'method =「post」'以便讀取'