Current location: Hot Scripts Forums » Programming Languages » PHP » variable Question


variable Question

Reply
  #1 (permalink)  
Old 05-23-05, 08:20 AM
aladdin83 aladdin83 is offline
New Member
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
Post variable Question

Hi every one >>

i have this problem that's been bothering me and here it is :

how can i pass a variable used in one file to another file ...
eg .
in the file hello.php i have a variable called $Bold and it equals true
and what i want to do is open another file called welcome.php and test the value of $Bold ! yes its that simple ! but how can i do it ?

thanks a lot every one >>>
Reply With Quote
  #2 (permalink)  
Old 05-23-05, 08:53 AM
NeverMind's Avatar
NeverMind NeverMind is offline
Community VIP
 
Join Date: Aug 2003
Location: K.S.A
Posts: 2,257
Thanks: 0
Thanked 2 Times in 1 Post
many ways to do that!
you can use sessions, cookies, get or post variables!

you can pass the value of $Bold in URL like:
welcome.php?Bold=true
and then access it with:
$_GET['Bold']

or you can post it in a form and retraive it with:
$_POST['Bold']

to use sessions, you have to start your session with session_start() and set the value of the session with:
$_SESSION['Bold'] = 'true';
and retraive it with:
$_SESSION['Bold']

finaly cookies. to set a cookie use:
setcookie('Bold', "true", time()+3600);

to retraive it use:
$_COOKIE['Bold']


HTH
__________________
PHPSimplicity
We don't need a reason to help people - Zidane [FF9]
Reply With Quote
  #3 (permalink)  
Old 05-24-05, 01:47 PM
aladdin83 aladdin83 is offline
New Member
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
thanks a lot for your reply ...
i'll give it a try and let you know >>>
Reply With Quote
  #4 (permalink)  
Old 05-24-05, 04:21 PM
aladdin83 aladdin83 is offline
New Member
 
Join Date: May 2005
Posts: 3
Thanks: 0
Thanked 0 Times in 0 Posts
am i doing somthing wrong ?

well i tried the $_Session way scince its the most convenient way to do what i am trying to do but it didn't work !

here is my code :

i have the file input.php inside of it i included the file formcode.php

so the value of bold gets set in the file formcode.php and gets tested in the file input.php but the result is null ! the bold doesn't contain a value at all !

what is wrong ?

thanx again >>>
Reply With Quote
  #5 (permalink)  
Old 05-24-05, 04:37 PM
FiRe FiRe is offline
Code Guru
 
Join Date: Oct 2004
Location: UK
Posts: 801
Thanks: 0
Thanked 0 Times in 0 Posts
u need to put 'session_start();' at the very beginning of the code!
__________________
Alexa Share <-- Trade virtual shares in websites with this online game.

codR.us <-- Submit and vote for your favorite code snippets with codR.us.

XEWeb.net <-- The ultimate PHP resource network.
Reply With Quote
Reply

Bookmarks


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

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
what is the best method to find last word in variable ? GS300 PHP 6 09-15-04 09:13 PM
[PHP] Array question UmiSal Script Requests 1 04-05-04 01:52 PM
question and answer software jaydifox C/C++ 0 02-21-04 09:26 AM
Call a variable name dynamically Kenrette ASP 2 11-12-03 09:48 AM


All times are GMT -5. The time now is 06:46 AM.
vBulletin® Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.