so the php script will be placed at another php file...and the xhtml use the code above to call the php script?
i'm still quite blur..so sorry...
thanks in advance..
how to create text on php generated image?
Moderators: onion2k, General Moderators
- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
i went through a tutorial and found out the code
" <DIV style="position: absolute; top:511px; left:428px; width:94px; height:24px">text</DIV>"
now, the text can be placed on the shirt...but how to code, if i wanna let user add the text by entering the text on input box, then click on submit button..the text will displayed on shirt?
thanks in advance
" <DIV style="position: absolute; top:511px; left:428px; width:94px; height:24px">text</DIV>"
now, the text can be placed on the shirt...but how to code, if i wanna let user add the text by entering the text on input box, then click on submit button..the text will displayed on shirt?
thanks in advance
the text can be displayed on the image already
code is "[/quote]
code is "
Code: Select all
<DIV style="position: absolute; top:511px; left:428px; width:94px; height:24px">
<?php
echo " " . $_POST["text2write"] . "<br/>";
?></DIV>
however, the text will be only displayed on this particular page. So, if user click button 'click to preview' which will lead user to next page and preview the image with the text again, do i nid to save the text into the database?
or passing the variable is sufficient enough?
thanks in advance!- John Cartwright
- Site Admin
- Posts: 11470
- Joined: Tue Dec 23, 2003 2:10 am
- Location: Toronto
- Contact:
passing the code should be sufficient enough.. I would probably pass the input through htmlentities() just to be safe aswell
-
MilkmanDan
- Forum Newbie
- Posts: 1
- Joined: Wed Jun 14, 2006 8:21 pm
Followup
I've been lurking and lurning, and thought I'd ask this in here instead of a new thread. In R4000's example (below) I'm pretty sure I have a handle on whats happening throughout, and I have no problem getting it to run.....but when displaying the created image......if I try to "Right-click/Save" the generated image it will only save the php-form. What else has to be there for the image to be savable from the browser window?
I also have tried a few different ways of escaping the php to insert some text along with the generated pic. No Dice, and I'm thinking there's something here I just am not "getting". I thought that ?>Text Here<?php would work, but it just starts displaying what looks like the code for the image.
Any clues here would be greatly appreciated!
I also have tried a few different ways of escaping the php to insert some text along with the generated pic. No Dice, and I'm thinking there's something here I just am not "getting". I thought that ?>Text Here<?php would work, but it just starts displaying what looks like the code for the image.
Any clues here would be greatly appreciated!
R4000 wrote:Should do exactly what you wantCode: Select all
<?php if($_POST['text2write']){ $im = imagecreate(100, 30); // white background and blue text $bg = imagecolorallocate($im, 255, 255, 255); $textcolor = imagecolorallocate($im, 0, 0, 255); imagestring($im, 5, 0, 0, $_POST['text2write'], $textcolor); header("Content-type: image/png"); imagepng($im); } else { ?> <form action="<?=$_SERVER['PHP_SELF']?>" method="POST"> Text to write on image: <input name="text2write" value="" type="text" /><br /> <input type="submit" name="submit" value="Write It!" /> </form> <?php } ?>