2017-05-29 43 views
1

我有一個這樣的形式:文件名是 「main.php」中使用會話的Oracle 11g R2(11.0.2)

<html> 

    <form action = "options.php" method = "POST" /> 
     <p> <h3> Enter Phone Number: </h3> <input type = "text" name = 
"cust_phone" /> 
     <p> <input type = "submit" value = "Submit" /> 
    </form> 
    </html> 

的 「options.php」 看起來是這樣的:

 <html> 
     <body> Details of: <?php session_start(); 
     echo htmlentities($_POST["cust_phone"]) . "<br>"; 
     $link = oci_connect('hd','hd', 'localhost/mydb'); 
     if(!$link) { 
      $e = oci_error(); 
      exit('Connection error ' . $e['message']); 
     } 
     $_SESSION['var'] = $_POST["cust_phone"]; 
     echo $_SESSION['var']; 
     $ph = htmlentities($_POST["cust_phone"]); 
     $q1 = "select CUST_ID from customer where CUST_PHONE = :bv_ph"; 
     $q1parse = oci_parse($link, $q1); 
     oci_bind_by_name($q1parse, ':bv_ph', $ph); 

    oci_execute($q1parse); 
    oci_fetch($q1parse); 
    $res = oci_result($q1parse, 'CUST_ID'); 
    if(!$res) { 
     echo "No Order found. New Order?"; 
    } 
    ?> 
    <form action = "" method = "POST" > 
     <input type = "radio" name = "option" value = "Yes" checked> Yes 
    <br> 
     <input type = "radio" name = "option" value ="No"> No <br> 
     <input type = "submit" value = "submit"> 
    </form> 
    <?php 

     if(isset($_POST['option']) && ($_POST['option']) == "Yes") { 
       header("Location: newcustomer.php"); 
     } 
     elseif(isset($_POST['option']) && ($_POST['option']) == "No") { 
      header("location: main.php"); 
     } 

    ?> 
    </body> 

的 「newcustomer.php」 看起來是這樣的:

<!DOCTYPE HTML> 
    <html> 
    <body> 
    <form action = "order.php" method = "POST" > 
    <p> Phone Number: </p> 

    <p> Enter Address: <input type = "text" name = "address" /></p> 
    <p> Enter Area: <input type = "text" name = "area" /></p> 
    </form> 
    <?php 
      session_start(); 
     echo $_SESSION ['var']; 
     ?> 
</body> 
</html> 

我想數量的用戶在 「main.php」 輸入的值在我無法實現的「newcustomer.php」中使用。我是否正確使用會話變量?運行「newcustomer.php」時的結果不顯示任何錯誤,但不會回顯「$ _SESSION ['var']」。

回答

0

你應該寫在session_start()在每一頁禮帽......

<?php 
    session_start(); 
?> 
<html> 
..... 
...... 
+0

我做到了。它仍然不起作用。它在相同的文件「options.php」中工作,但不在「newcustomer.php」中。 –

+0

你應該同樣在session_start()中newcustomer.php –

+0

我在所有的文件中做過。仍然沒有錯誤,但沒有顯示。 –