Jump to content

noob question re: sessions and forms


crunchie

Recommended Posts

I'm almost embarrassed to ask such a simple question but I just cannot get this to work.  I'm trying to figure out how to use sessions  that takes the information from a form on the first page and displays it on the last.

I have this on page 1:

<?php

session_start();

?>

<form action="test2.php" method="post">

<p>Page 1</p>

<p>First Name <input type="text" name="first" /></p>

 

<p><input type="submit" value="Next page 2"  /></p>

 

And this for page 2:

<?php

SESSION_START();

 

$_SESSION['first'] = $_POST['first'];

echo $_SESSION['first'] = $_POST['first'];

 

?>

<form action="test3.php" method="post">

<p>Page 2</p>

<input type="submit" value="Next page 3" />

</form>

 

And this for page 3:

<?php

SESSION_START();

 

$_SESSION['first'] = $_POST['first'];

echo $_SESSION['first'] = $_POST['first'];

 

?>

 

<p>Page 3</p>

<p>You're done</p>

 

I can get it to display on page 2 but not on page 3.  Can anyone tell me why?  I've been at this for a long time and it should be simple but I cannot get it to work.  Thanks in advance.

Link to comment
https://forums.phpfreaks.com/topic/261332-noob-question-re-sessions-and-forms/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.