gpt4 book ai didi

php - 在第二页转发表单中显示输入名称

转载 作者:行者123 更新时间:2023-11-29 07:38:36 24 4
gpt4 key购买 nike

我有两种形式。我想在第二个中显示 mobile,mobile 将通过 session 进入。此处显示 session ID,但未显示 mobile

第一个表格/页面:sign.php

<?php session_start();
<?php $r=session_id();?>
<?php include('include/config.php');?>
<form class="ff" action="signc.php" method="POST">
<a>Enter Your Mobile No.</a>
<input type="text" id="inp" name="mobile" required>
</br></br>
<input type="submit" id="btn" value="continue">
</form>

signc.php

<?php session_start();
<?php $r=session_id();?>
<?php include('include/config.php');?>
$sql = mysqli_query($connection, "INSERT INTO `mobile_message` SET `mobile` = '$mobile'");

if($sql){

$_SESSION['s']= "OTP sent to your mobile.";
header('Location:sign2.php');

} else{
$_SESSION['e']= "Could not able to execute. ";
header('Location:sign.php');

}

第二个表格/页面:sign2.php

<?php session_start();
<?php $r=session_id();?>
<?php include('include/config.php');?>
<form class="ff" action="sign2c.php" method="POST">
<a class="ase" >Enter Your Mobile No.</a>
<?php
$cid=$_SESSION['cid'];
$_q=mysqli_query($connection, "select * from mobile_message where mobile='$cid'");
$_t=mysqli_fetch_array($_q);
echo $_t['mobile'];
echo $r;
?>
</br></br>
<a class="ase" >Enter Password</a>
<input type="text" id="inp" name="otp" required>
</br>
<input type="submit" id="btn" value="continue">
</form>

<!--hgfh-->

echo $_t['mobile']; 什么都不显示

echo $r; 显示 cgvk2tla6r14h38i2v7dlhkj80

最佳答案

只需在 signc.php 中添加这两行即可

$cid=$_POST['mobile'];

$_SESSION['cid']=$cid;

更正后的 signc.php 会像

<?php session_start();
<?php $r=session_id();?>
<?php include('include/config.php');?>
$sql = mysqli_query($connection, "INSERT INTO `mobile_message` SET `mobile` = '$mobile'");

if($sql){

$cid=$_POST['mobile'];

$_SESSION['cid']=$cid;

$_SESSION['s']= "OTP sent to your mobile.";
header('Location:sign2.php');

} else{
$_SESSION['e']= "Could not able to execute. ";
header('Location:sign.php');

}

关于php - 在第二页转发表单中显示输入名称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47553736/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com