Previous Thread
Next Thread
Print Thread
Rate Thread
#252048 06/23/2003 1:24 PM
Joined: Jul 2002
Posts: 79
Power User
Power User
Offline
Joined: Jul 2002
Posts: 79
I hope it is ok to post this question here
I am trying to add an interactive php form on my forum that allows people to display an image depending on the options they choose. It should reload the page they are currently on to display the image.
I know this won't work but it might give an idea of what I am looking for:

Code
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>"><br /><select name="Pet"><br /><option value="Acara">Acara</option><br /><option value="Aisha">Aisha</option><br /><option value="Blumaroo">Blumaroo</option><br /><option value="Bruce">Bruce</option><br /></select><br><br /><select name="Colour"><br /><option value="Red">Red</option><br /><option value="Yellow">Yellow</option><br /><option value="Green">Green</option><br /><option value="Blue">Blue</option><br /></select><br><br /><input type="submit" name="Show Me!" value="Show Me!"><br /></form><br /><br /><img src="<? print $Pet ?>_<? print $Colour ?>.gif"> 


Is this even possible with PHP? Any ideas would be greatly appreciated!

Sponsored Links
Joined: Aug 2002
Posts: 1,191
Kahuna
Kahuna
Joined: Aug 2002
Posts: 1,191
It seems that you are nearly there. All you have to do is retrieve the passed variables $Pet and $Colour from the $HTTP_POST_VARS array and check them before you print them as an image.

If you look at the ubbt.inc.php the getinput function is a very good start on how to retrieve variables passed on your script. All you have to do then is check if those variables are empty and if not then you will either display a default image or nothing at all

if (!$Pet and !$Colour) {
// display nothing
} else {
echo "<img src="$Pet" />$Colour";
}

I haven't tried this but it should work.


Nikos
Hal_dup2 #252050 06/23/2003 3:22 PM
Joined: Apr 2002
Posts: 1,768
Addict
Addict
Offline
Joined: Apr 2002
Posts: 1,768
Code
<?php<br /><br />if ($_POST['Pet'] and $_POST['Colour']) {<br />   echo "<img src=\"{$_POST['Pet']}\" />{$_POST['Colour']}";<br />}<br /><br />?>

joeuser #252051 06/23/2003 9:12 PM
Joined: Jul 2002
Posts: 79
Power User
Power User
Offline
Joined: Jul 2002
Posts: 79
Thanks so much to both of you! It works like a charm


Link Copied to Clipboard
Donate Today!
Donate via PayPal

Donate to UBBDev today to help aid in Operational, Server and Script Maintenance, and Development costs.

Please also see our parent organization VNC Web Services if you're in the need of a new UBB.threads Install or Upgrade, Site/Server Migrations, or Security and Coding Services.
Recommended Hosts
We have personally worked with and recommend the following Web Hosts:
Stable Host
bluehost
InterServer
Visit us on Facebook
Member Spotlight
Posts: 70
Joined: January 2007
Forum Statistics
Forums63
Topics37,573
Posts293,925
Members13,849
Most Online5,166
Sep 15th, 2019
Today's Statistics
Currently Online
Topics Created
Posts Made
Users Online
Birthdays
Top Posters
AllenAyres 21,079
JoshPet 10,369
LK 7,394
Lord Dexter 6,708
Gizmo 5,833
Greg Hard 4,625
Top Posters(30 Days)
Top Likes Received
isaac 82
Gizmo 20
Brett 7
WebGuy 2
Morgan 2
Top Likes Received (30 Days)
None yet
The UBB.Developers Network (UBB.Dev/Threads.Dev) is ©2000-2024 VNC Web Services

 
Powered by UBB.threads™ PHP Forum Software 8.0.0
(Preview build 20240506)