Forum Moderators: coopster

Message Too Old, No Replies

Passing variables via URL string

It's not working!

         

sgconard

7:18 pm on Dec 17, 2003 (gmt 0)

10+ Year Member



This is (or should be) so simple but it's not working. I have JavaScript popup a PHP page and passes a variable via the URL string. Here's the JS function:

function goVideo(vname){
vpath = "videos/" + vname;
theURL = "video.php?id=" + vpath;
window.open(theURL,'vid','toolbar=no,location=no,status=no,menubar=no,scrollbars=no,resizable=no,width=620,height=256');
}

In video.php I have these lines of code:

$vfile = $id;
echo '<PARAM NAME="src" VALUE="'.$vfile.'">';

This doesn't work. When viewing the HTML source of the page the line above is:

<PARAM NAME="src" VALUE="">

However, if I change $vfile = $id to $vfile = "path/file.mov" it works fine. Hmmmmmm...

Thanks,
Steve

mipapage

7:22 pm on Dec 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



woul this work?
updated
$vfile = $_GET[id];
echo "<PARAM NAME=\"src\" VALUE=\"$vfile\">";

sgconard

7:30 pm on Dec 17, 2003 (gmt 0)

10+ Year Member



YES! Woowhoo! I needed the $_GET part. Not sure why but it works.

Thanks so much!
Steve

mipapage

7:43 pm on Dec 17, 2003 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



Glad it helped.

Why:
You can start here [php.net].

But basically, any variables in the URL are accessed from /contained in the $_GET superglobal, which is an array that holds those values ('Getting' the values from the HTTP header).

So, for example in

www.mysite.com?id=WebmasterWorld&what=rocks

$_GET[id] = WebmasterWorld
$_GET[what] = rocks