sican Posted June 16, 2009 Share Posted June 16, 2009 Hi there, I have a problem with php, I've been looking around but I haven't found what I'm searching for.. The idea: Now I have a user clicking on a link and directing him to a page where the wallpaper is. I want to change that and add more elements to that page, not only the image (like header, footer). And I though of doing it with PHP. The link would lead to a wallpaper.php file and the image's URL requested would be displayed. I have only gotten this far: <?php $file = 'http://www.website.com/something/image.jpg';?> <img src="<?php echo $file ?>" alt="something" width="600px" height="434px" /> But how can I save the requested URL from a previous page and add/pass it to $file so that it displays the image I requested? For example, check out this website: http://vladstudio.com/home/. When you click a link, it displays on the address bar www.something.com/?cheshire_kitten which loads the image chesire_kitten I think it does an http request, right? I don't know maybe there is an easier way to do this, if so I'm all ears! Thanks in advance! Link to comment https://forums.phpfreaks.com/topic/162403-how-to-passforward-a-url/ Share on other sites More sharing options...
premiso Posted June 16, 2009 Share Posted June 16, 2009 You would use GET data, you may want to look into mod_rewrite to do exactly what you want. But the idea: <?php $image = isset($_GET['image'])?$_GET['image']:null; if (stristr($image, ".jpg") !== false) { $file = 'http://www.website.com/something/' . $image; }else { $file = 'http://www.website.com/something/no-image.jpg'; } ?> <img src="<?php echo $file ?>" alt="something" width="600px" height="434px" /> Then calling: yoursite.com/wallpaper.php?image=image.jpg Would pullup image.jpg etc. That is a rough description, but hopefully gets you moving in the right direction. You may want to invoke a file_exists to make sure the image exists before displaying it as well. Link to comment https://forums.phpfreaks.com/topic/162403-how-to-passforward-a-url/#findComment-857196 Share on other sites More sharing options...
sican Posted June 16, 2009 Author Share Posted June 16, 2009 Nice premiso, will look up mod_rewrite and file_exists, but yes, I think that's what I'm looking for! I'll give it a try and come back if I can't solve it! Thanks a lot! Link to comment https://forums.phpfreaks.com/topic/162403-how-to-passforward-a-url/#findComment-857231 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.