本文介绍了如何在PHP编码中区分用户和管理员的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨....

i想要一个小帮助...

我是php编码的新手......

i已经设定了我学院的一个项目..

i制作了一个登录和注册应用程序......但我无法混合用户和管理员代码..

我可以提供任何帮助..

用户表包括用户名,电子邮件,密码

和管理员相同的东西...

please ...

并提前致谢..

以下代码用于登录用户..

登录管理员我创建了一个新表并插入了他的数据..

如何创建两个使用同一个表的一个php文件..

请帮助....



我尝试过:





$ email = $ _POST [email ];

$ pass = $ _POST [password];

需要inti.php;





$ query =select * from userinfo where email like'。$ email。'和密码如'。$ pass。';;

$ result = mysqli_query($ con,$ query);



if(mysqli_num_rows($ result)> 0)

{

$ response = array();

$ code =login_true;

$ row = mysqli_fetch_array($ result);

$ name = $ row [0];

$ message =login sucess ...。$ name;

array_push($ response,array(code=> $代码,message=> $ message));

echo json_encode(array(server_response=> $ response));



}



其他

{

$ response = array();

$ code =login_false;

$ message =登录失败.....再试一次..;

array_push($ response,array( code=> $ code,message=> $ message));

echo json_encode(array(server_response=> $ response));

}

mysqli_close($ con);

?>

解决方案



hi....
i want a small help...
am new to php coding...
i have been desiging a project for my college..
i made a login and registration app... bt i am unable to mix the user and admin code..
can i hav any help..
user table consists of username,email,password
and admin the same things...
please...
and thanks in advance..
the below code is for login of user..
for login of admin i created a new table and inserted he data..
how to create both of the using a same table a one php file..
please help....

What I have tried:


$email = $_POST["email"];
$pass = $_POST["password"];
require "inti.php";


$query = "select * from userinfo where email like '".$email."' and password like '".$pass."';";
$result = mysqli_query($con,$query);

if(mysqli_num_rows($result)>0)
{
$response = array();
$code = "login_true";
$row = mysqli_fetch_array($result);
$name = $row[0];
$message = "login sucess...".$name;
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array("server_response"=>$response));

}

else
{
$response = array();
$code = "login_false";
$message = "login failed.....try again..";
array_push($response,array("code"=>$code,"message"=>$message));
echo json_encode(array("server_response"=>$response));
}
mysqli_close($con);
?>

解决方案




这篇关于如何在PHP编码中区分用户和管理员的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-21 15:12