User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 375,205 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,356 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 28027 | Replies: 3
Reply
Join Date: Aug 2004
Posts: 22
Reputation: Decency is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
Decency Decency is offline Offline
Newbie Poster

How Can I Pass A PHP Variable From One .php page to another

  #1  
Oct 22nd, 2004
hey, i've been in a middle of a problem about passing a php variable from one .php page to another?
for example:
if im in a middle of sign.php which has a variable called $username:
this user name is to be known through all the rest .php pages in my project
as long as the cookies for this user name are set.
thank you.
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Sep 2004
Location: in the j00-kay
Posts: 114
Reputation: ReDuX is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 5
ReDuX's Avatar
ReDuX ReDuX is offline Offline
Junior Poster

Re: How Can I Pass A PHP Variable From One .php page to another

  #2  
Oct 23rd, 2004
If you are already setting the username in a cookie
e.g.
[PHP]setcookie("your_cookie", $username, time()+99999999, "/", ".domain.name.com", 0);[/PHP]

Then you can just check it's set:
[PHP]$_COOKIE['your_cookie'][/PHP]

on top of that you can check the username variable, along with passwords, and compare them to the contents of a database for example.
I'm pink, therefore, im spam.
http://www.vivaci.net - Quality Webhosting
http://gaming.vivaci.net - FAST UK Gaming servers
http://www.getsigned.org - Free Image Uploads
Reply With Quote  
Join Date: Sep 2004
Location: Delaware, USA
Posts: 417
Reputation: Young Teck 06 is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 0
Young Teck 06's Avatar
Young Teck 06 Young Teck 06 is offline Offline
Street Game CEO

Re: How Can I Pass A PHP Variable From One .php page to another

  #3  
Oct 23rd, 2004
Wouldnt you be able to simply use a include function or some sort, or can you not. I know phpBB does it.
Need Website Work... PM Me or EMail Me at mdstreetsoulja@gmail.com ... I am AVAILABLE!
Reply With Quote  
Join Date: Oct 2004
Location: France / Paris
Posts: 14
Reputation: fpepito is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
fpepito fpepito is offline Offline
Newbie Poster

Re: How Can I Pass A PHP Variable From One .php page to another

  #4  
Oct 24th, 2004
A little example: (try it in http://fpepito.dyndns.org/test.php)

I hope that help you,

pepito

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

<?

$myname = $PHP_SELF;
session_register ("session");

if (isset ($session[lang])) {
// if user choice another language, update the session[lang]
if (isset ($lg)) { $session[lang] = $lg;}

echo "Session existe, you have enter: $session[count] times<BR>";
echo "Your actual language is: $session[lang]<BR>";

setlocale ("LC_TIME", $session[lang]);
echo strftime ("%c")."<BR>";

// You need locale file corresponding with the next language
echo "<A HREF=$myname?lg=fr_FR>Utiliser le français</A><BR>";
echo "<A HREF=$myname?lg=en>Use english langage</A><BR>";
echo "<A HREF=$myname?lg=pt_PT>Utilizar o portugues</A><BR>";
// update counter
$session[count] = $session[count] + 1;
} else {
echo "It's the first time that you coming. We will create session:<BR>";
$session[lang] = $HTTP_ACCEPT_LANGUAGE;
$session[count] = 1;
echo "<A HREF=$myname>reload</A>";
}

?>
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

DaniWeb PHP Marketplace
Thread Tools Display Modes

Similar Threads
Other Threads in the PHP Forum

All times are GMT -4. The time now is 2:44 am.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC