dongqiao2077 2017-11-29 08:05
浏览 38
已采纳

如何在下一页显示插入数据

I have two form. In the second page mobile no is not showing.

echo $_r['mobile']; in the second form is showing nothing.

I add every page :

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

1st form / page: 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');

}

2nd form / page: 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>
  • 写回答

1条回答 默认 最新

  • doudang4857 2017-11-30 07:49
    关注

    Change the line $cid=$_POST['mobile']; instead $cid=$sql['mobile']; in signc.php

    $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');
    
    }
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 做个有关计算的小程序
  • ¥15 MPI读取tif文件无法正常给各进程分配路径
  • ¥15 如何用MATLAB实现以下三个公式(有相互嵌套)
  • ¥30 关于#算法#的问题:运用EViews第九版本进行一系列计量经济学的时间数列数据回归分析预测问题 求各位帮我解答一下
  • ¥15 setInterval 页面闪烁,怎么解决
  • ¥15 如何让企业微信机器人实现消息汇总整合
  • ¥50 关于#ui#的问题:做yolov8的ui界面出现的问题
  • ¥15 如何用Python爬取各高校教师公开的教育和工作经历
  • ¥15 TLE9879QXA40 电机驱动
  • ¥20 对于工程问题的非线性数学模型进行线性化