【问题标题】:The randomly generated OTP for mobile verification is not updating to DB用于移动验证的随机生成的 OTP 未更新到数据库
【发布时间】:2016-12-28 07:35:08
【问题描述】:

我正在做一个项目,我必须验证用户的手机号码。我已经生成了 otp 并将其成功交付给移动用户。但是 otp 变量在更新 mysql 查询中没有显示任何值。在 echo 上打印结果。

代码在这里:

if(isset($_POST['mobile']))
{
    include_once("connectionfile.php");
    $string = 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ';
    $string_shuffled = str_shuffle($string);
    $otpCode = substr($string_shuffled, 1, 7);
    echo '<br/>'. $otpCode;
    file_get_contents("http://www.sms99.com/ComposeSMS.aspx?username=sample&password=sample&sender=sample&to=$payMob&message=$password&priority=1&dnd=1&unicode=0");
    echo '</br>'.$otpCode;
    $optQry = "update clients set mobile='$payMob', address='$payAddress', city='$payCity', country='$payCountry', opt_code='$optCode' where id = '$payClient'" ;
    echo $optQry; 
    $qryRes = mysqli_query($con, $optQry)or die("query Error");
    print_r($optRes);
}

输出画面:

1E2ewz7

update clients set mobile='4422336699', address='new way', city='fkldsjl', country='IN', opt_code='' where id = '131'

【问题讨论】:

    标签: php mysql mobile


    【解决方案1】:

    您的变量中似乎有错字。

    $optQry 中的$optCode 更改为$otpCode

    【讨论】:

      【解决方案2】:

      试试这个:

      $optQry = "update clients set mobile='$payMob', address='$payAddress', city='$payCity', country='$payCountry', opt_code='$otpCode' where id = '$payClient'" ;
      

      【讨论】:

      • 它正在工作。但是我错了我也写了相同的查询
      【解决方案3】:

      您没有在查询中使用完全相同的变量,请使用以下内容:

      $optQry = "update clients set mobile='$payMob', address='$payAddress', city='$payCity', country='$payCountry', opt_code='$otpCode' where id = '$payClient'" ;

      只需使用$otpCode 即可。

      如果有帮助请标记为正确。

      谢谢

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2020-08-20
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多