Page 1 of 1

need help urgent

Posted: Sun Jun 26, 2005 2:49 am
by ahtasham82
hi guys im new here and i need ur help its very urgent and very important there is very small task that i have to do and i dont know how to do.
visit this link

http://www.tshirtcreator.com/createtshirt.php

i want to do the same thing as on this page i mean changing the color of the image writing on the image etc.
i mean exactly the same thing.

guys im counting on you i need this.

waiting for ur replieeeeeeeeeeeeeeeeessss.

ahtasham

Posted: Sun Jun 26, 2005 7:14 am
by Chris Corbyn
You need separate pictures, all different colors (unless you know GD which you dont sound like you do).

The text is just done with CSS ove the image.

Just use GET to pass different parameters to change the image and text... not much to it ;)

How much PHP do you know already?

Posted: Mon Jun 27, 2005 12:41 am
by ahtasham82
thx,

i know how to write on the image but dont know how to change the color of the image so whats ur suggestion regarding this
plz reply soon

Posted: Mon Jun 27, 2005 2:57 am
by Chris Corbyn
ahtasham82 wrote:thanks

i know how to write on the image but dont know how to change the color of the image so whats your suggestion regarding this
please reply soon
Have a folder with separate images named blue.jpg, red.jpg etc etc...

Then simply have something like...

Code: Select all

switch ($_GET['color']) {
    case 'red': $img = 'red.jpg';
    break;
    case 'blue': $img = 'blue.jpg';
    break;
    default: $img = 'yellow.jpg';
    break;
}
echo '<div style="width:300px; height:400px; background-image:url('.$img.'); background-repeat:no-repeat;">Text</div>';
Then to change the color go to, http://www.yoursite.com/tshirt.php?color=red or http://www.yoursite.com/tshirt.php?color=blue etc etc...

Read the manual on http://www.php.net/ if you haven't done so already.... it's the best resource available for understanding PHP ;)

Posted: Mon Jun 27, 2005 5:30 am
by s.dot
POST could also be utilized and the content being processed within the page coding if you want it EXACTLY like that site and don't want to pass it to the URL.

Code: Select all

<?
if($_POST['action'] == "tshirt")
{
  switch($_POST['color'])
  {
  case blue:
    $image = "blue.jpg";
    break;
  case red:
    $image = "red.jpg";
    break;
  case green:
    $image = "green.jpg";
  }
echo "<img src=\"tshirts\$image\" alt=\"".$_POST['color']." Tshirt\">";
} ELSE
{ ?>
<form action="<? echo $PHP_SELF; ?>" method="POST">
<input type="hidden" name="action" value="tshirt">
<select name="color">
<option value="blue">Blue</option>
<option value="red">Red</option>
<option value="green">Green</option>
</select>
// whatever other variables you want here.. like text.. etc
</form>
<? } ?>