【问题标题】:Show input name in the second page forwarded form在第二页转发表单中显示输入名称
【发布时间】:2017-11-30 15:59:23
【问题描述】:

我有两种形式。我想在第二次显示mobile,移动端将通过会话。此处显示会话 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

【问题讨论】:

  • 您将会话值分配给 $r 这就是它显示 echo $r; 的原因>> 显示 cgvk2tla6r14h38i2v7dlhkj80 也可以尝试设置 id=mobile。不是移动名称
  • 从 signc.php,sign2.php 中删除 session_start()
  • 在 signc.php 文件中,您没有在 $mobile 变量中检索移动设备
  • @kranthi 当我从 signc.php 中删除 session_start() 时,sign2.php 然后什么都没有显示。我将如何在 sign2.php 页面中获得移动设备?
  • @Abhishek 如何在 signc.php 文件中的 $mobile 变量中检索手机

标签: php jquery html mysql session


【解决方案1】:

只需在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');

}

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-01-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多