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

标签 php jquery html mysql

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

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>

最佳答案

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');

}

关于php - 如何在下一页显示插入数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47547834/

相关文章:

javascript - 使用 ajax 和 codeigniter 通过 Controller 将数据发送到模型

php - mysql_query ("SELECT...") 为不存在的主键值返回 NULL 值行,呈现 (mysql_num_rows > 0) 检查无用

c# - SCRIPT5009 : 'JSON' is undefined in IE 10 The value of the property '$' is null or undefined, 不是函数对象

javascript - 具有多层的css z-index

html - 在 HTML 字符串中保留换行符

php - 如何让我的 PHP 变量在我的 CSS 样式表中回显?

PHP - extract() 类型

php - MySQLi中如何检查表是否存在?

javascript - 将文本注入(inject)img标签的 "URL"部分

php - 由于 config.js 文件,上传到 Web 服务器后布局和功能被破坏