By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
457,699 Members | 1,325 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 457,699 IT Pros & Developers. It's quick & easy.

How to pass a same variable across mutiple pages using sessions

P: 34
hi
i cant pass a same variable to multiplepages...
while passing variables in sessions
it shows warning and it doesn't pass to multiple pages
here the coding which i hve used
Registration.php
<?
session_start();
session_register("username");
$username=$_POST['t3'];
?>
Registration1.php
<?
session_start();
echo "".$username;
?>
update.php
<?
session_start();
echo "".$username;
$q1="UPDATE `realtour` SET list='$protype' where uname='$username'";
?>

in the above....
i cant get the value of username where used in Registration1.php
can anyone suggest me
Jan 23 '07 #1
Share this Question
Share on Google+
3 Replies


ronverdonk
Expert 2.5K+
P: 4,258
Passing variables can best be done via the $_SESSION array.
If your script uses session_register(), it will not work in environments where the PHP directive register_globals is disabled.
So in your case it is best to code as follows:
[php]Registration.php:
------------------
<?php
session_start();
$username=$_POST['t3'];
$_SESSION['username'] = $username;

Registration1.php:
------------------
<?php
session_start();
echo $_SESSION['username'];

update.php:
-----------
<?php
session_start();
$username = $_SESSION['username'];
echo $username;
[/php]

Ronald :cool:
Jan 23 '07 #2

P: 34
Hi
thanks for ur suggestion
its working well
Jan 24 '07 #3

ronverdonk
Expert 2.5K+
P: 4,258
You are most welcome.

Ronald :cool:
Jan 24 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.