I have a form like this: The file name is "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>
The "options.php" looks like this:
<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>
</html>
The "newcustomer.php" looks like this:
<!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>
I want the value of the number entered by the user in "main.php" to be used in "newcustomer.php" which I am not able to achieve. Am i using the session variable correctly? The result when I run "newcustomer.php" does not show any error but does not echo the "$_SESSION['var']".
[Updated on: Mon, 29 May 2017 08:28]
Report message to a moderator