用户在php PDO中已存在错误 [英] user already exists error in php PDO

查看:90
本文介绍了用户在php PDO中已存在错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对每一个人来说都是...我在php中的新手,并与PDO交互到mysql。 iam将使用



 if来过滤用户输入数据(!filter_input(INPUT_POST,'   $ username')||!filter_input(INPUT_POST,'  $ password'))
{
echo 用户名或密码已存在....;

}

else
{
$ sql = INSERT INTO用户(用户名,密码)VALUES(:用户名,:密码) ;
$ q = $ dbh-> prepare($ sql);
$ q->执行(数组(' :username' => $ username ,' :password' => $ password));
$ count = $ q-> rowCount();
echo inserted $ count rows.\\ \\ n;



但它显示错误...错误是它只是显示消息



用户名密码已存在





如果用户名或密码不存在则显示相同的消息?我能做什么?如果有人有任何想法然后把它放到我的代码...如果filter_input()没有使用她那么我可以使用insted ... plz解决它...谢谢'在先进..

解决方案

用户名')||!filter_input(INPUT_POST,'


password'))
{
echo 用户名或密码已存在....;

}

else
{


sql = INSERT INTO用户(用户名,密码) )VALUES(:用户名,:密码);


hy to every one.. iam new in php and working with PDO interaction to mysql. iam going to filter user input data using

if(!filter_input(INPUT_POST,'$username')||!filter_input(INPUT_POST,'$password'))
        {
            echo "username or password already exists....";

        }

        else
        {
$sql = "INSERT INTO users (Username,Password) VALUES (:username,:password)";
$q=$dbh->prepare($sql);
$q->execute(array(':username'=>$username,':password'=>$password));
$count=$q->rowCount();
echo "inserted $count rows.\n";


but it show an error... the error is that it simply show the message

username or password already exists



if the username or password is not exists it show the same message? what can i do? if some one have any idea then put it to my code... if the filter_input() is not used her then what can i use insted of... plz solve it... thank''s in Advance..

解决方案

username')||!filter_input(INPUT_POST,'


password')) { echo "username or password already exists...."; } else {


sql = "INSERT INTO users (Username,Password) VALUES (:username,:password)";


这篇关于用户在php PDO中已存在错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆