Solved

PHP Sessions

Posted on 2009-07-04
1
221 Views
Last Modified: 2012-05-07
Hi all I need to record into a session a value passed by a form to the same page. It' like this I need to fill a form and call the same page recording all the values in a session. How should I go about it?
Thanks.
0
Comment
Question by:doRodrigo
1 Comment
 
LVL 5

Accepted Solution

by:
yauhing earned 500 total points
ID: 24778696
Please try below example:

If value "name" was found in the $_POST, it will be added to the session.
<?php
session_start(); // start the session
 
if(isset($_POST['name'])){
	// if the name post from previous page, set it to the session
	$_SESSION['name'] = $_POST['name'];
}
?>
<pre>
Existing Session:
<?php 
	// print out the session value
	print_r($_SESSION); 
?>
</pre>
 
Input form for test:<br>
<form method="post">
Name: <input type="text" name="name" value="Test Name">
<input type="submit">
</form>

Open in new window

0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Popularity Can Be Measured Sometimes we deal with questions of popularity, and we need a way to collect opinions from our clients.  This article shows a simple teaching example of how we might elect a favorite color by letting our clients vote for …
This article discusses how to implement server side field validation and display customized error messages to the client.
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

733 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question