2017-11-29 4 views
2

私は2つのフォームを持っています。第2ページでは、モバイルは表示されません。次のページにデータを挿入する方法

echo $_r['mobile'];は、第2の形式では何も表示していません。

<?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> 
+0

ラインは、クエリで "エコー$のCID" にしてみてください。それは動作しますか? –

+0

私は "echo $ cid"を試みましたが、結果はありませんでした。 –

答えて

1

変更$cid=$_POST['mobile'];代わり$cid=$sql['mobile'];

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

} 
関連する問題