Solved

PHP Sessions

Posted on 2009-07-04
1
186 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
Comment Utility
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

Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

Join & Write a Comment

Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
This article discusses four methods for overlaying images in a container on a web page
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to count occurrences of each item in an array.

728 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

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now