[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

PHP Sessions

Posted on 2009-07-04
1
Medium Priority
?
229 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 5

Accepted Solution

by:
yauhing earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

Part of the Global Positioning System A geocode (https://developers.google.com/maps/documentation/geocoding/) is the major subset of a GPS coordinate (http://en.wikipedia.org/wiki/Global_Positioning_System), the other parts being the altitude and t…
These days socially coordinated efforts have turned into a critical requirement for enterprises.
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
Suggested Courses

656 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