【问题标题】:How to show insert data in the next page如何在下一页显示插入数据
【发布时间】:2017-11-29 08:05:45
【问题描述】:

我有两种形式。在第二页没有显示手机号码。

echo $_r['mobile']; 在第二种形式中没有显示任何内容。

我添加每一页:

<?php session_start();?>
<?php include('include/config.php');?>

第一种形式/页面:sign.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

$sql = mysqli_query($connection, "INSERT INTO `mobile_message`  SET `mobile` = '$mobile'");

 if($sql){

        $cid=$sql['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');

}

第二个表格/页面:sign2.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'");
    $_r=mysqli_fetch_array($_q);
    echo $_r['mobile'];
    ?>
</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>

【问题讨论】:

  • 尝试使用查询“回显 $cid”。有用吗?
  • 我试过 "echo $cid" 但没有结果。

标签: php jquery html mysql


【解决方案1】:

signc.php 中更改$cid=$_POST['mobile']; 而不是$cid=$sql['mobile'];

$sql = mysqli_query($connection, "INSERT INTO `mobile_message`  SET `mobile` = '$mobile'");

 if($sql){

        $cid=$_POST['mobile'];   # write instead  $cid=$sql['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');

}

【讨论】:

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