Forum Moderators: coopster
$a = $_POST['a'];
$b = $_POST['b'];
$c = $_POST['c'];
$d = $_POST['d'];
$_SESSION['a'] = $a;
$_SESSION['b'] = $b;
$_SESSION['c'] = $c;
$_SESSION['d'] = $d;
File B also contains another HTML form. The design of this form is dependant upon the variable $a. This form will send the field data e and f to File C. I planned on using $_SESSION[] to get the values of a,b,c and d in File C but it doesn't work. I tried using $_SESSION[] in File B and it works just fine.
Hope that wasn't too confusing.
I have placed the session_start() above all my php files:
<?php
session_start();
header("Cache-control: private");
?>
My register_globals have been set to off and I'm currently using PHP version 4.3.4
Could someone help me please?
page with the form on it.
<?
session_start();
header("Cache-control: private");
?>
<form method="POST" action="page.php">
<input name="input1">
<input name="input2">
<input type="submit" name="submit">
</form>
page.php
<?php
session_start();
header("Cache-control: private");
$_SESSION['a'] = $_POST['input1'];
$_SESSION['b'] = $_POST['input2'];
$input1 = $_SESSION['a'];
$input2 = $_SESSION['b'];
echo $input1;
echo $input2;
?>
this might be what you are looking for.
In file A, I have a HTML form which contains a text field called "first_name". I can post the data to file B without any problems.
*** excerpt code in B ***
$name = $_POST['first_name'];
Now in file B, the user needs to fill in another form which will be posted to file C. Besides the new data which will be posted, I also want to send the value saved in $name to file C. I figured that I could use sessions to register the value $name so that I could call it in file C.
*** excerpt code in B ***
$_SESSION['name'] = $name;
However, the value does not appear in file C when I call it. I get nothing.
*** excerpt code in C ***
echo $_SESSION['name'];
When I type the above code in file B, it works and displays the first name. It just won't work in file C.
Is this a bug or am I doing something wrong?
I'm relatively new to PHP sessions. I learnt up sessions from here:
[phpfreaks.com...]