Jump to content

how to pass/forward a URL?


sican

Recommended Posts

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

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.

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.