如何保存文本本地';s在数据库php中发送otp?

如何保存文本本地';s在数据库php中发送otp?,php,one-time-password,Php,One Time Password,我正在创建一个OTP系统,在该系统中,我从我的客户那里收集一些信息,他也会在其中输入他的号码,当他单击提交按钮时,OTP将发送给他。现在我想将OTP保存在数据库中以供进一步使用。我使用文本本地发送OTP这是我的代码 <!DOCTYPE html> <html> <head> <title>Send SMS from PHP using textlocal</title> <link rel="stylesheet"

我正在创建一个OTP系统,在该系统中,我从我的客户那里收集一些信息,他也会在其中输入他的号码,当他单击提交按钮时,OTP将发送给他。现在我想将OTP保存在数据库中以供进一步使用。我使用文本本地发送OTP这是我的代码

<!DOCTYPE html>
<html>
<head>
    <title>Send SMS from PHP using textlocal</title>
    <link rel="stylesheet" href="../css/bootstrap.min.css">
</head>
<body>
<div class="container">
<h1 class="text-center">Sending OTP SMS </h1>
<hr>
    <div class="row">
    <div class="col-md-9 col-md-offset-2">
        <?php
            if(isset($_POST['sendopt'])) {
                require('textlocal.class.php');
                require('credential.php');

                $textlocal = new Textlocal(false, false, API_KEY);

                // You can access  from credential.php
                // $numbers = array(MOBILE);
                // Access enter mobile number in input box
                $numbers = array($_POST['mobile']);

                $sender = 'TXTLCL';
                $otp = mt_rand(10000, 99999);
                $message = "Hello " . $_POST['uname'] . " This is your OTP: " . $otp;

                try {
                    $result = $textlocal->sendSms($numbers, $message, $sender);
                    setcookie('otp', $otp);
                    echo "OTP successfully send..";
                } catch (Exception $e) {
                    die('Error: ' . $e->getMessage());
                }
            }

            if(isset($_POST['verifyotp'])) { 
                $otp = $_POST['otp'];
                if($_COOKIE['otp'] == $otp) {
                    echo "Congratulation, Your mobile is verified.";
                } else {
                    echo "Please enter correct otp.";
                }
            }
        ?>
    </div>
    <div class="col-md-9 col-md-offset-2">
        <form role="form" method="post" enctype="multipart/form-data">
            <div class="row">
                <div class="col-sm-9 form-group">
                    <label for="uname">Name</label>
                    <input type="text" class="form-control" id="uname" name="uname" value="" maxlength="10" placeholder="Enter your name" required="">
                </div>
            </div>
            <div class="row">
                <div class="col-sm-9 form-group">
                    <label for="mobile">Mobile</label>
                    <input type="text" class="form-control" id="mobile" name="mobile" value="" maxlength="10" placeholder="Enter valid mobile number" required="">
                </div>
            </div>
            <div class="row">
                <div class="col-sm-9 form-group">
                    <button type="submit" name="sendopt" class="btn btn-lg btn-success btn-block">Send OTP</button>
                </div>
            </div>
            </form>

    </div>
</div>
</body>
</html>

使用textlocal从PHP发送SMS
发送OTP短信

名称 可移动的 发送OTP
我怎样才能做到这一点呢?任何形式的帮助都将不胜感激