有没有办法提交一份表格,然后再为我提交另一份表格



我正在尝试向某个电话号码发送OTP,该电话号码是使用PHP从mySQL数据库中提取的。目前的工作方式:

1.用户输入一封电子邮件并单击登录按钮。

2.OTP是随机生成并存储在数据库中的。

3。检索到与电子邮件关联的电话号码。

然而,我使用的短信服务使用表格将数据提交给第三方发送文件。我的问题是,我需要首先检索数据,然后将这些数据用作我的另一个表单的参数并提交它。但我不知道我是否只需一个按钮就能完成所有这些。

下面是我的表单,它调用登录文件。

<form action="login.php" method="POST">
<div class="form-signin">
<h2 class="form-signin-heading"></h2>
<?php if ($_REQUEST['s'] == 't') { ?>
<label for="clientToken" class="sr-only">Verification Code</label>
<input type="text" name="clientToken" id="clientToken" class="form-control" placeholder="6 digit Token" required autofocus><br>
<?php } else { ?>
<label for="clientEmail" class="sr-only">Email</label>
<input type="text" autocomplete="clientEmail" name="clientEmail" id="clientEmail" class="form-control" placeholder="Email" required autofocus><br>
<?php } ?>
<input class="btn btn-lg btn-danger btn-block" type="submit" value="Login"></input><br>
<?php if ($_REQUEST['s'] == 'f') { ?>
<div class="text-center text-white">No such email exists in our records</div>
<?php } ?>
</div>
</form>

下面是调用SMS发送服务的表单,我正试图在login.php文件完成从mySQL数据库检索数据后发送该服务。

<form id="sms" action="https://api.silverstreet.com/send.php" method="post">
<table align="center">
<tr style="display: none">
<td>Username</td>
<td>: <input type="text" name="username" value="name" readonly="readonly"></td>
</tr>
<tr style="display: none">
<td>Password</td>
<td>: <input type="text" name="password" value="pass" readonly="readonly"></td>
</tr>
<tr style="display: none">
<td>Destination</td>
<td>: <input type="text" name="destination" value="number"> Eg: 60125555555</td>
</tr>
<tr style="display: none">
<td>Sender</td>
<td>: <input type="text" name="sender" value="name"></td>
</tr>
<tr style="display: none">
<td>Body</td>
<td>: <textarea name="body" rows="4" cols="50">OTP here</textarea></td>
</tr>
<tr style="display: none">
<td align="center" colspan="2"><input type="submit"></td>
</tr>
</table>
</form>

有没有办法让我能做到这一点?还是我需要两个单独的按钮?

您可以使用php-ccurl从服务器提交表单(或发送请求(。

login.php中,从数据库中检索信息后,您可以提交curl请求,如下代码所示:

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, 'https://api.silverstreet.com/send.php');
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, http_build_query(
array(
"username" => "<username>",
"password" => "<password>",
"sender" => "hello",
"body" => "hello world.",
"destination" => "1234567890,1234567891"
)
));
$result = curl_exec($ch);
if(curl_errno($ch)){ echo curl_errno($ch); }
curl_close($ch));
?>

参考:https://www.silverstreet.com/api-documents/?php#portal-短信提交

最新更新