Milonic provide full featured pull down web menus for some of the worlds largest companies
click here to see what it can do for you

Download Milonic DHTML Menu
Buy Milonic DHTML Menu

Back To Start Of Archive
Taken From The Forum: Help & Support for DHTML Menu Version 5+
Forum Topic: Click to view post
Last Updated: Saturday July 14 2012 - 06:07:22

Passing vars from PHP


Poster: Alec
Dated: Friday February 15 2008 - 12:07:53 GMT

Hi Guys

I'm having problems passing vars from php to the menu_data file

I've renamed my menu_data file to menu_data.php as described in a topic on here, but it's still not passing the var.

The URL is http://locatea.net/modules.php?name=Cou ... ay&ref=coc

The var I'm trying to pass is &ref=coc

If you miss &ref=coc off the url, it loads the websites logo, if &ref=xxx it loads the members logo.

In the menu > Icons > Jobs > Jobs by day > Today's Jobs you will see the URL has &ref= on the end of it, but it doesnt pick up the var from PHP.

I've tried everything I can think of, inclding making global $ref; in just about everywhere but without luck.

My mil file is at http://www.locatea.net/mil/menu_data.php

Any ideas?

Re: Passing vars from PHP


Poster: Andy
Dated: Friday February 15 2008 - 12:15:27 GMT

What exactly does the line look like in the .php file?

All I can see is aI("text=Only show vehicles;url=modules.php?name=Courier_Map4&mapcontent=vehicles"); but it's been parsed already so cannot see how you are calling the parameter

Re: Passing vars from PHP


Poster: Alec
Dated: Friday February 15 2008 - 12:24:13 GMT

Hi, the line in the data_menu.php file looks like this...

aI("text=Today's jobs;url=modules.php?name=Courier_Map4&display=today&ref=<?php echo $ref; ?>");

Thanks :D

Re: Passing vars from PHP


Poster: Andy
Dated: Friday February 15 2008 - 12:38:51 GMT

Can you try this and let me know if it works:

Code:
aI("text=Today's jobs;url=modules.php?name=Courier_Map4&display=today&ref=<?php echo $_REQUEST['ref']; ?>");

Re: Passing vars from PHP


Poster: Alec
Dated: Friday February 15 2008 - 12:46:07 GMT

Hi Andy,

Tried that one already, doesn't seem to work... It's in place now if you want to take a look.

:D

Re: Passing vars from PHP


Poster: Andy
Dated: Friday February 15 2008 - 13:00:46 GMT

Hi,

You know what, it's actually working.

See here:

http://www.locatea.net/mil/menu_data.php?ref=1234

Then look at the source you'll see a ref=1234 in there.

What's happening is the parent page HAS the variable attached to it but the menu page does not.

So, in your html, instead of just this:
Code:
<script type="text/javascript" src="mil/menu_data.php"></script>


try this:

Code:
<? echo "<script type='text/javascript' src='mil/menu_data.php?ref=$_REQUEST[ref]'></script>" ?>


This should pass the variable to the menu file.

HTH,
Andy

Re: Passing vars from PHP


Poster: Alec
Dated: Friday February 15 2008 - 13:05:32 GMT

Cool...

It worked, thanks for saving me a day of head scratching ! :lol:

Well pleased with the script guys, keep up the good work.

:D

Re: Passing vars from PHP


Poster: Alec
Dated: Friday February 15 2008 - 13:13:03 GMT

I forgot to add [ so others can do it ]

At the very start of menu_data.php add this

Code:
<?php
$ref = $_REQUEST['ref'];
?>


then you can get the var using <?=$ref?> which saves a bit of space!

like this..

Code:
aI("text=Today's jobs;url=modules.php?name=Courier_Map4&display=today&ref=<?=$ref?>");

Re: Passing vars from PHP


Poster: Andy
Dated: Friday February 15 2008 - 13:24:09 GMT

Thanks for that.

That's how PHP used to be years ago before they introduced register_globals in their php.ini file.

If you change it to register_globals = On it will allow you to just access the form variable by name but it does open the script/server to possible security hacks.

Glad you got it working :D