hlcornish Posted September 9, 2010 Share Posted September 9, 2010 Hi guys, I have written a page that contains a form. When the user chooses a color, it is posted, then the posted value is re-written as a filename, sent through a function, and the image on the page uses the "colorized.gif" created by the function to make an image swap "onclick. Problem is, no matter the choice, it always changes the picture to orange! Here is the code for the form: <?php include('function.php'); ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>PHP GD CONFIGURATOR</title> </head> <body> <form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post"> Red<input type="radio" name="color" value="red" /> Orange<input type="radio" name="color" value="orange" /> Ivory<input type="radio" name="color" value="ivory" /> Black<input type="radio" name="color" value="black" /> <input type="submit" name="submit" value="submit" /> </form> <?php if($_POST['color'] != NULL){ echo $_POST['color']; $file =('gdimages/' . $_POST['color'] . '.gif'); createImg($file); } ?> <img src="default.jpg" name="lola" alt="lola dining chair" onclick="this.src = 'colorized.gif'" /> </body> </html> And here is the function... function createImg ($imgname1) { $base = imagecreatefromgif("gdimages/base.gif"); $top = imagecreatefromgif($imgname1); if ($top) { imagecopy($base, $top, 0, 0, 0, 0, 250, 250); imagejpeg($base, 'colorized.gif'); imagedestroy($base); } else{ header("Content-Type: text/html"); } } I really can't understand it...this is my first attempt at programming something new by myself...and I really need it to work!!! I also plan for this to work with combining more than 2 images from more than two choice menus...so debugging now is definitely necessary. Any suggestions? Quote Link to comment https://forums.phpfreaks.com/topic/212966-php-based-img-swap-always-turning-up-orange-version/ Share on other sites More sharing options...
hlcornish Posted September 9, 2010 Author Share Posted September 9, 2010 Okay, so i've figured out it is just an IE issue...in Firefox it loads correctly and you can keep changing the color correctly. In IE once you've chosen it once, it won't give you any other color picture. Help! What do you even do for that? Quote Link to comment https://forums.phpfreaks.com/topic/212966-php-based-img-swap-always-turning-up-orange-version/#findComment-1109198 Share on other sites More sharing options...
hlcornish Posted September 9, 2010 Author Share Posted September 9, 2010 http://www.hlcornish.com/phpgd/config.php Here is the link to the form page, if anyone wants to try to give a different diagnosis. Thanks! Quote Link to comment https://forums.phpfreaks.com/topic/212966-php-based-img-swap-always-turning-up-orange-version/#findComment-1109228 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.