| | |
How Can I Pass A PHP Variable From One .php page to another
Please support our PHP advertiser: PostgreSQL or MySQL? Compare and contrast the two most popular open source databases
![]() |
•
•
Join Date: Aug 2004
Posts: 22
Reputation:
Solved Threads: 1
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.
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.
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.
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
http://www.vivaci.net - Quality Webhosting
http://gaming.vivaci.net - FAST UK Gaming servers
http://www.getsigned.org - Free Image Uploads
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!
•
•
Join Date: Oct 2004
Posts: 14
Reputation:
Solved Threads: 1
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>";
}
?>
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>";
}
?>
![]() |
Similar Threads
- NEED help to pass javascript variable to php (PHP)
- pass the javascript variable to php page (PHP)
- Pass a javascript variable to PHP in the same function (JavaScript / DHTML / AJAX)
Other Threads in the PHP Forum
- Previous Thread: Php portal install help!!
- Next Thread: PHP Include ... Quote quirk
| Thread Tools | Search this Thread |
5.2.10 action apache api array beginner beneath binary broken cakephp checkbox class classes cms code cron curl database date destroy display dynamic echo echo$_get[x]changingitintovariable... email encode error fcc file files folder form forms function functions google header howtowriteathesis href htaccess html image images include insert ip javascript joomla limit link local login mail memberships menu mlm mod_rewrite multiple multipletables mysql mysqlquery neutrality oop open passwords paypal pdf php provider query radio random record remote rss script search server sessions sockets source space sql strip_tags syntax system table template thesishelp tutorial update upload url validator variable video voteup web window.onbeforeunload=closeme; youtube





