leaded
4th January 2005, 09:48 PM
I have 3 php pages. The first two are forms and the third redisplays the form fields' values.
I want to use $_SESSION to store all of my form values because I'll be working on 3 or 4 pages eventually and I want to be able to call them up easily. I have a previous version of what I'm trying to do but I have to session_register EVERY value. All I knew at the time was some ASP and I used a ASP to PHP converter and it turned it into crap. Now I'm trying to make a clean and polished PHP script but I'm having a little bit of trouble.
Basically I'm trying to add the values of $_POST to the existing $_SESSION. It doesn't work tho... here's my code...
test1.php<html>
<body>
<form method="post" action="test2.php">
Church Name: <input type="text" name="name" size="50"><br>
Church Phone: <input type="text" name="phone" size="50"><br>
<input type="submit">
</form>
</body>
</html>
test2.php<?php
session_start();
$_SESSION = $_POST;
?>
<html>
<body>
<form method="post" action="test3.php">
Contact Name: <input type="text" name="contact_name" size="50"><br>
Contact Phone: <input type="text" name="contact_phone" size="50"><br>
<input type="submit">
</form>
Testing form 1's values...<br>
<?php
echo $_SESSION['name'];
echo $_SESSION['phone'];
?>
</body>
</html>
test3.php<?php
session_start();
array_push($_SESSION, $_POST);
?>
<html>
<body>
Name: <?php echo $_SESSION['name']; ?><br>
Phone: <?php echo $_SESSION['phone']; ?><br><br>
Contact name: <?php echo $_SESSION['contact_name']; ?><br>
Contact phone: <?php echo $_SESSION['contact_phone']; ?><br>
</body>
</html>
This only displays $_SESSION['name'] and $_SESSION['phone']. I also tried $_SESSION .= $_POST; But that just outputted "A" for each value for some reason.
I'm not a PHP pro, I'm teaching myself, and I'm stuck here. Once I can get this concept working I can build up the rest of my forms.
Thanks in advance!
I want to use $_SESSION to store all of my form values because I'll be working on 3 or 4 pages eventually and I want to be able to call them up easily. I have a previous version of what I'm trying to do but I have to session_register EVERY value. All I knew at the time was some ASP and I used a ASP to PHP converter and it turned it into crap. Now I'm trying to make a clean and polished PHP script but I'm having a little bit of trouble.
Basically I'm trying to add the values of $_POST to the existing $_SESSION. It doesn't work tho... here's my code...
test1.php<html>
<body>
<form method="post" action="test2.php">
Church Name: <input type="text" name="name" size="50"><br>
Church Phone: <input type="text" name="phone" size="50"><br>
<input type="submit">
</form>
</body>
</html>
test2.php<?php
session_start();
$_SESSION = $_POST;
?>
<html>
<body>
<form method="post" action="test3.php">
Contact Name: <input type="text" name="contact_name" size="50"><br>
Contact Phone: <input type="text" name="contact_phone" size="50"><br>
<input type="submit">
</form>
Testing form 1's values...<br>
<?php
echo $_SESSION['name'];
echo $_SESSION['phone'];
?>
</body>
</html>
test3.php<?php
session_start();
array_push($_SESSION, $_POST);
?>
<html>
<body>
Name: <?php echo $_SESSION['name']; ?><br>
Phone: <?php echo $_SESSION['phone']; ?><br><br>
Contact name: <?php echo $_SESSION['contact_name']; ?><br>
Contact phone: <?php echo $_SESSION['contact_phone']; ?><br>
</body>
</html>
This only displays $_SESSION['name'] and $_SESSION['phone']. I also tried $_SESSION .= $_POST; But that just outputted "A" for each value for some reason.
I'm not a PHP pro, I'm teaching myself, and I'm stuck here. Once I can get this concept working I can build up the rest of my forms.
Thanks in advance!