PHP:页面没有正确重定向,重定向太多

时间:2016-11-13 07:21:23

标签: php postgresql redirect

我尝试实现一个系统,其中用户输入他的用户名和电话号码,当提交表单时,它检查数据库以根据它的存在来验证号码和用户名。 SMS将发送到该号码。他得到一个弹出窗口输入OTP代码。

然而,在输入OTP代码时,我收到重定向循环的错误。我只是解释下面文件的流程:

INDEX.PHP - > LOGIN.PHP - > OTP.PHP - > CHECK_OTP.PHP - > HOME.PHP

这些是正在使用的文件。它到达otp页面,当你进入时,它确实成功验证,但它进入循环。我将发布代码以查看OTP身份验证代码的错误。

session_start(); // Starting Session
$error=''; // Variable To Store Error Message
if (isset($_POST['verify'])) {
if (empty($_POST['otp'])) {
$error = "OTP is invalid";
}
else
{
// Post OTP
$otp=$_POST['otp'];
}
$otp = stripslashes($otp);
$otp = pg_escape_string($otp);
$check = "select * from otp where otp = '$otp'";
$ret_check = $dbConnection->executeQuery($check);
$ret_num = $dbConnection->numRows($ret_check);
$cust_code = '';
while($row = $dbConnection->fetchRow($ret_check)){
    $cust_code = $row[0];
}
$cust_code;
if($ret_num != 1){
    $error = "Wrong OTP entered";
    header("Location: otp-home.php");
}
else {
    echo $_SESSION['login_user'] = $cust_code;
    header("Location: home.php");
}

我希望这就够了。如果需要其他任何东西。请告诉我。任何帮助将不胜感激。谢谢

0 个答案:

没有答案