[英]Displaying Information based on entered value in PHP with Oracle Database 11g R2
[英]Using Sessions in PHP with Oracle 11g R2 (11.0.2)
我有一個這樣的表格:文件名是“main.php”
<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']”。
你應該在每個頁面頂部編寫session_start()...
<?php
session_start();
?>
<html>
.....
......
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.