Need help sending url passed variables to an outside file

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
johnm1019
Forum Newbie
Posts: 4
Joined: Sat Jul 12, 2003 11:26 pm

Need help sending url passed variables to an outside file

Post by johnm1019 »

Hello, my first post so here we go.....

On my site i have a javascript menu, but the links in the menu need some of the variables i passed in my url to succesfully generate good url's...

For example....

say the url to the following website is
mysite.com/admin.php?adminid=blah

Code: Select all

<html>
<body>
Hi!
<SCRIPT language=JavaScript src="vertical_data.php" type=text/javascript></SCRIPT>
</body>
</html>
Now in that code snippet, some of php code in the vertical_data.php (which i might add for those of u that are confused; yes the PHP is embedded within the javascript) file needs to be able to use that adminid variable and after my attempts to echo $adminid within that vertical_data.php file I found out $adminid is not getting 'passed' (if you will). What do i need to do to allow that vertical_data.php file to grab that adminid variable?

Is this where i need to use sessions? If so any quick implementation examples?
Are there any questions you people have so i can better explain the problem? As you can tell i've had a hard time forming a question which also lowers the probability of googling this so... srry if its ez!

Thanks so much! :oops:
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

I say use cookies. At the top of each page adminid is used as a GET variable set a cookie with the contents of adminid. Then call the cookie contents within the PHP of the js file. Hope it works.


btw; have you tried:

Code: Select all

<html> 
<body> 
Hi! 
<?
$adminid = $_GET&#1111;'adminid'];
?>
<SCRIPT language=JavaScript src="vertical_data.php?adminid=blabla" type=text/javascript></SCRIPT> 
</body> 
</html>
johnm1019
Forum Newbie
Posts: 4
Joined: Sat Jul 12, 2003 11:26 pm

Post by johnm1019 »

Thank u so much!
Gosh darn i knew it was just something simple....
It was 1 am and my brain was going in circles but thanks so much!
:D
Post Reply