首先我已经使用类完成了它,但实际上我必须使用curl来完成它。我想将我的电子邮件用户名和密码发送到系统,然后使用此值进行登录检查并重定向到table.php
这是我尝试的服务:
case 'LOGIN':
$uname = strip_tags($_POST['txt_uname_email']);
$upass = strip_tags($_POST['txt_password']);
$staffuname =$comingdata[0];
$staffpassword =$comingdata[1];
try
{
$login = $myPDO->query("SELECT * FROM users WHERE (user_name='{$uname}' OR user_email='{$uname}') AND user_pass='{$upass}' ")->fetch(PDO::FETCH_ASSOC);
if($login->rowCount() > 0 )
{
Redirect('table.php');
}else{
$data=array("Response"=>"Failed");
}
}
catch(PDOException $e)
{
echo $e->getMessage();
}
break;
这是curl登录后的帖子:
if(isset($_POST['btn-login']))
{
$uname = strip_tags($_POST['txt_uname_email']);
$upass = strip_tags($_POST['txt_password']);
$query=$uname.'|'.$upass;
echo $query;
$params=array(
'action' => "LOGIN",
'query' => $query
);
$postData='';
foreach($params as $k => $v){
$postData .= $k . '='.$v.'&';
}
rtrim($postData, '&');
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL,"http://localhost/skynebtrack/pages/dutyservice.php");
curl_setopt($ch, CURLOPT_POST, count($params));
curl_setopt($ch, CURLOPT_POSTFIELDS,$postData);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = curl_exec($ch);
print_r($response);
curl_close ($ch);
$cvp=json_decode($response,true);
if($cvp["Response"]=="SUCCESSFULL")
{
$_SESSION['user_session'] = $userRow['user_id'];
redirect('table.php');
}
else
{
}
}
我正在获取ıname和密码,但这并没有将我重定向到主页。感谢您的反馈。