<?php
include('db_conx.php');
$username= $_POST ['username'];
$password= $_POST ['password'];
//Test:
echo "<h1>Username: $username</h1>";
echo "<h1>Password: $password</h1>";
$mysqli=new mysqli
('localhost','1800758_robbie','mypassword', '1800758_robbie');
$stmt=$mysqli->prepare("SELECT username, password FROM
1800758_robbie.users3 WHERE username=? AND password=? LIMIT 1");
**$stmt->bind_param('ss', $username,$password);**
$stm->execute();
$stmt-> store_result();
$res=$stmt->num_rows();
if($res == 1) {echo "You have successfully logged in.";}else{echo " the
username and password you've supplied is not valid.";}
?>
我曾尝试阅读其他几篇文章,但没有一篇与此代码相符。我很遗憾为什么我不断收到此错误消息。我想要做的就是为论坛创建一个成功的登录页面。顺便说一下,我的所有登录信息都是正确的。
答案 0 :(得分:-2)
在您的准备语句中看起来像是一个错误。试试这个:
"SELECT username, password FROM users3 WHERE username=? AND password=? LIMIT 1"
您不需要引用users3
表的数据库名称,您已在数据库连接中指定了该表。如果仍然无效,请确保您的表实际上包含名为username
和password
的字段。