473,511 Members | 16,252 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

$_sessions

how do you save multiple variables in a multiple page form to $_SESSION
in order to retrieve them later...?

Jul 17 '05 #1
10 4834
Quinonez,

I assume you are asking how to set and use sessions. In order to use
sessions you must put the following at the very top of every page.

<?php session_start(); ?>

Once you have done that you can use sessions on the page. Now to set a
session you do the following

$_SESSION['name']="John";

This will set the session named, "name" with the value of "John." Then
you could echo it back out like so.

echo $_SESSION['name'];

and it would print out the word, 'John.' I hope this is what you
wanted. :)

Jul 17 '05 #2
If you need further help check out this page on Sessions. ->
http://us2.php.net/manual-lookup.php...ssions&lang=en

Jul 17 '05 #3
Quinonez,

I assume you are asking how to set and use sessions. In order to use
sessions you must put the following at the very top of every page.

<?php session_start(); ?>

Once you have done that you can use sessions on the page. Now to set a
session you do the following

$_SESSION['name']="John";

This will set the session named, "name" with the value of "John." Then
you could echo it back out like so.

echo $_SESSION['name'];

and it would print out the word, 'John.' I hope this is what you
wanted. :)

Jul 17 '05 #4
it does,
another question though is i have a form w. multiple variables its
actually a multiple page form and what i was wondering is if there is
away other than just setting up a $_SESSION['variablename'] for each
variable is there a way to have it save itself so that i can call at
the end of the form

Jul 17 '05 #5
yea but i have a lot of variables in a multiple page form do i have to
set it up like that for every variable or can it be automated and then
called at the end?

Jul 17 '05 #6
I guess you could do something like the following. On your html page
with all of the forms you could make the name attribute to a number
starting from 0 and going up. Here is an example of what I mean.

--------------[ HTML File ] -----------------------------
<!----Messy HTML Code. Example only.--->
<html>
<head><title>Test Page</title></head>
<body>
<b>Enter your name: </b><input type="text" name="0">
<b>Enter your phone: </b><input type="text" name="1">
<form action="file.php" method="post">
<input type="submit" value="Submit"></form>
</body></html>

---------------------------------------------------------------------

---------------[File.php]--------------------------------------------

<?php

session_start();

for($m=0;$m<2;$m++)
{
$_SESSION['$m']=$_POST['$m'];
}

?>

----------------------------------------------------------

The above code should work. If it dosen't then it's because $m dosen't
need to be in the '. This code is only to give you an example of what I
mean. :)

Jul 17 '05 #7
Quinonez wrote:
yea but i have a lot of variables in a multiple page form do i have to
set it up like that for every variable or can it be automated and then
called at the end?

==== page1.php
$_SESSION['page1'] = $_POST;

==== page2.php
$_SESSION['page2'] = $_POST;
echo $_SESSION['page1']['name'];

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #8
"==== page2.php
$_SESSION['page2'] = $_POST;
echo $_SESSION['page1']['name'];"

what am i supposed to put in where it says ['name']? where do i get
that from?

thank for all your help.. i love the groups!

Jul 17 '05 #9
Quinonez wrote:
"==== page2.php
$_SESSION['page2'] = $_POST;
echo $_SESSION['page1']['name'];"

what am i supposed to put in where it says ['name']? where do i get
that from?


Try

==== page2.php
echo '<pre>'; print_r($_SESSION['page1']); echo '</pre>';

--
Mail to my "From:" address is readable by all at http://www.dodgeit.com/
== ** ## !! ------------------------------------------------ !! ## ** ==
TEXT-ONLY mail to the whole "Reply-To:" address ("My Name" <my@address>)
may bypass my spam filter. If it does, I may reply from another address!
Jul 17 '05 #10
Pedro Graca said...
Quinonez wrote:
"==== page2.php
$_SESSION['page2'] = $_POST;
echo $_SESSION['page1']['name'];"

what am i supposed to put in where it says ['name']? where do i get
that from?


Try

==== page2.php
echo '<pre>'; print_r($_SESSION['page1']); echo '</pre>';


Also, consider using an object.

--
Best,
Marc

www.auxbuss.com
'SX Unleashed' is on the way.
Jul 17 '05 #11

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
7769
by: Paul | last post by:
Hmmm, didn't seem to work. I have set session.use_cookies = 1 and session.use_trans_sid = 1 in my php.ini file. Index.php contains:...
22
2844
by: Theo | last post by:
Question for the group The authentication system for the site Im working on seems to function properly and all is good. A session keeps track of everything and a cookie is used to accept or deny...
3
2733
by: quinonez | last post by:
i have a 7 page form and many many many variables.. i cant figure out how to get the variables to move from each page and show after it is submitted. I can get the last page of the form to show on...
1
2150
by: Greg Bacchus | last post by:
Hi, I'm using a IObjectReference object to help deserialize a SessionInfo class. But with a catch: What I want to do is have it so that a SessionInfo Id is serialized and in deserialization the...
2
2080
by: Gavin Lyons via .NET 247 | last post by:
Hello, I'm writing a newsletter application which uses backgroundthreading. I'm using Session variable to report on progresswhile it loops through a dataset. The 'Status.aspx' pagerefreshes every...
7
9338
by: pank | last post by:
hey guys ... can anybody tell me a php logout script. I want to log out from one page which i was developing , i tried but it's not working. I have tried session_destroy(),session_unset()...
12
8278
by: mankolele | last post by:
Hi all, users usually have usernames and passwords, and can log in to many maches at once withe same details. What I want to do is restrict them to only one machine if they have already LOGGED-ON...
25
2371
by: chazzy69 | last post by:
is it possible to send information without having to use a php form i.e. say the information that you would put in the form is made as a sort of message that can be posted automatically without...
8
1623
by: kevin21388 | last post by:
I am getting say a persons name over a tcp connection. The problem is that when I do this : Dim buffSize As Integer Dim inStream(10024) As Byte buffSize =...
0
7138
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7353
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7418
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
7075
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
3222
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3212
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
446
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.