View Full Version : PHP & JavaScript
rublind 01-07-2004, 03:43 PM I have a "Cool Stuff" page..
some content of the page was not forum-appropriate
And the popup windows are functions, but for the flash movies the title is the location to the file, is there a way to change the title without writing to much code?
Thanks.
Dude128 01-07-2004, 04:02 PM you could create one PHP file that you open in the popup, and put the file name of the movie and the title in the query string.
for example, you might create a movie.php page that you just take the file name and title for out of the query string and print to the page, and open movie.php?file=movie.ext&title=Movie
rublind 01-08-2004, 02:33 AM Yea, but then I have to write another page.. I really don't want to.. Is there another way?
bellportal 01-10-2004, 04:25 PM I think that this is the best way for you. If you are familiar with PHP, you can do what Dude128 says. If not, post and we can help you out.
rublind 01-11-2004, 07:36 AM Yea it would be something like this
<?php
$movie = $HTTP_GET_VARS['movie'];
?>
//Lots of flash mumboly jumboly
<?php echo $movie; ?>
Is no problem.
Dude128 01-11-2004, 03:59 PM in that code, you don't need $movie, and in new versions of PHP, you would need to use $_GET, not $HTTP_GET_VARS
so you could do this:
<html>
<head>
<title><?php echo "$_GET['title']"; ?></title>
</head>
<body>
<...movie code src="<?php echo "$_GET['movie']"; ?>" ...>
</body>
</html>
and open the page like I said in my last post- you can also change what you have in the query string, just make sure the names you use (such as movie and title) match the code above.
bellportal 01-11-2004, 04:38 PM Dude128 is right, you use $_GET.
The only other thing I was going to say was that you should add some extra code in which checks to make sure that the movie is where the URL says it is - as soon as a visitor sees that there are parameters in a URL, they can't help fiddling with them. :lol:
rublind 01-11-2004, 04:40 PM I think my version of PHP still allows $HTTP_GET_VARS, I prefer it as well because something about registering globals or what not. And do you have any ideas what kind of error checking I could do..? Is there a file_exists(); function.
bellportal 01-11-2004, 05:28 PM I'm afraid my PHP skills aren't as good as they used to - VB is getting in the way!
burntsushi 01-11-2004, 05:40 PM I think my version of PHP still allows $HTTP_GET_VARS, I prefer it as well because something about registering globals or what not. And do you have any ideas what kind of error checking I could do..? Is there a file_exists(); function.
Sure is :)
http://us2.php.net/manual/en/function.file-exists.php
Also, if i'm not mistaken, the $HTTP_GET_VARS array has been deprecated, and $_GET is i guess what you're supposed to use.. :)
Just out of curiosity, what did you mean by it had something to do with registering globals? :)
Dude128 01-11-2004, 05:47 PM yes, there is a file_exists function that you could use to check whether the file exists or not, and you could check the last three characters of the string to make sure it's the right file type, or if you're planning to use the same kind of file all the time, you could leave off the extension in the query string and just add it in to check whether the file exists or not and to display it.
bellportal 01-11-2004, 07:41 PM There is another way - slightly more complicated, but with less margin for error. I don't know if this is a feature of PHP, it is definately one in ASP.
Instead of passing args. to the page through the URL, create a form on the page which the popup is opened from, and create a hidden tag with the information you need i.e. movie and title. Then config. the PHP popup page to accept the information from the hidden form and voila! You have a better form already! :lol:
burntsushi 01-11-2004, 08:44 PM yea, that too would work... then you would use the $_POST array, instead of the $_GET array ;)
bellportal 01-14-2004, 03:26 PM Yeah... something like that!
bellportal 01-16-2004, 09:45 AM Sorry if it's not helpful enough - I am merely trying to say that I am not sure whether the code is 100% correct, or whether there are errors.
|