Welcome guest. Before posting on our computer help forum, you must register. Click here it's easy and free.

Author Topic: Allow user to specify background in URL  (Read 3747 times)

0 Members and 1 Guest are viewing this topic.

camerongray

    Topic Starter


    Expert
  • Thanked: 306
    • Yes
    • Cameron Gray - The Random Rambings of a Computer Geek
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Mac OS
Allow user to specify background in URL
« on: March 09, 2010, 10:54:57 AM »
Hi,

I'm working on a website that lets you choose a background image from placing it in the URL.

For example, if the URL is http://www.mysite.com?image=http://www.imagehost.com/cat.jpg, the page background will be the image at http://www.imagehost.com/cat.jpg

I think it is possible with PHP but I can't work out how to use it.

My server supports PHP, HTML and Javascript and I'd rather not use Flash

kpac

  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: Allow user to specify background in URL
« Reply #1 on: March 09, 2010, 11:00:51 AM »
Code: [Select]
<?php

$bg 
$_GET['image'];

echo 
"
<style type=\"text/css\">
  body {
    background-image: url(\"" 
$bg "\");
  }
</style>"
;

?>


etc. etc....

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Allow user to specify background in URL
« Reply #2 on: March 09, 2010, 11:02:18 AM »
something like this:
Code: [Select]
<html><head>
<title>Image Viewer</title>
</head>
<body>
<img src="<?php
echo $_GET['image'?>
">
</body>
</html>
I was trying to dereference Null Pointers before it was cool.

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Allow user to specify background in URL
« Reply #3 on: March 09, 2010, 11:02:35 AM »
curses
oh wait, background image. never mind, heh.
I was trying to dereference Null Pointers before it was cool.

camerongray

    Topic Starter


    Expert
  • Thanked: 306
    • Yes
    • Cameron Gray - The Random Rambings of a Computer Geek
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Mac OS
Re: Allow user to specify background in URL
« Reply #4 on: March 09, 2010, 11:19:34 AM »
Thanks - That worked  ;D

kpac

  • Web moderator
  • Moderator


  • Hacker

  • kpac®
  • Thanked: 184
    • Yes
    • Yes
    • Yes
  • Certifications: List
  • Computer: Specs
  • Experience: Expert
  • OS: Windows 7
Re: Allow user to specify background in URL
« Reply #5 on: March 09, 2010, 11:20:30 AM »
Which one? (please say mine...please say mine...) ;D

BC_Programmer


    Mastermind
  • Typing is no substitute for thinking.
  • Thanked: 1140
    • Yes
    • Yes
    • BC-Programming.com
  • Certifications: List
  • Computer: Specs
  • Experience: Beginner
  • OS: Windows 11
Re: Allow user to specify background in URL
« Reply #6 on: March 09, 2010, 11:21:45 AM »
Which one? (please say mine...please say mine...) ;D

Well I'd hope so, since your's changes the background like he wanted and mine just sorta forces in a img tag.
I was trying to dereference Null Pointers before it was cool.