Jump to content

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.

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.