yekis Posted December 7, 2007 Share Posted December 7, 2007 is it possible to convert a submitted web form into a jpg format.... see sample link/image below to get what i mean: http://www.geocities.com/yekis/phpInquiry.jpg hoping for your immediate reply...tnx Quote Link to comment Share on other sites More sharing options...
Barand Posted December 7, 2007 Share Posted December 7, 2007 Yes, you need the GD image functions http://www.php.net/manual/en/ref.image.php Quote Link to comment Share on other sites More sharing options...
yekis Posted December 10, 2007 Author Share Posted December 10, 2007 thanks for your reply...i already installed the gd library/image functions on my server..it works!! but please forgive me, i'm a newbie to php..heh 1) this is exactly what i want to happen in my web form Pls. see image http://www.geocities.com/yekis/sample.jpg 2) nevertheless, once i preview my site on a browser,,i keep on getting ascii error messages (trash characters) Pls. see image http://www.geocities.com/yekis/error.jpg 3) here's my full code (saves as delete.php) ...i can't find/determine the bug in my script..pls help me! tnx a lot <html> <head> <meta name="author" content="Rexcel Cariaga"> <link href="xampp.css" rel="stylesheet" type="text/css"> <title></title> </head> <body> <img src="background.png"> <form name="ff" action="delete.php" method="get"> <table width="294" border="0"> <tr> <td width="124"></td> <td width="160"></td> </tr> <tr> <td>Name Of Seller</td> <td><input type="text" name="text" size="25"></td> </tr> <tr> <td><p>Contact Number</p> </td> <td><label> <input name="contact" type="text" id="contact" size="25"> </label></td> </tr> <tr> <td>Product Name</td> <td><label> <input name="product" type="text" id="product" size="25"> </label></td> </tr> <tr> <td>Description</td> <td><label> <textarea name="description" cols="19" id="description"></textarea> </label></td> </tr> <tr> <td>Price</td> <td><label> <input name="price" type="text" id="price" size="25"> </label></td> </tr> <tr> <td> </td> <td><center><input type="submit" value="Submit"></center></td> </tr> </table> </form> <p> </body> </html> <?php //loads image?? $im = imagecreatefrompng("background.png"); //defines text color $textcolor = imagecolorallocate($im, 255, 255, 255); // write the string at the top left ?? imagestring($im, 5, 0, 0, $_GET['text'], $textcolor); //outputs the image header("Content-Type: image/png"); imagepng($im); imagedestroy($im); ?> Quote Link to comment Share on other sites More sharing options...
blueman378 Posted December 10, 2007 Share Posted December 10, 2007 noone will look at this till you use tags Quote Link to comment Share on other sites More sharing options...
yekis Posted December 10, 2007 Author Share Posted December 10, 2007 sorry..i didn't get what you mean... i'm a really a newbie to php..just copied the source code from a certain php website and modified it little by little until i got stuck..hehe ...what part of my code should i put the tags <code> </code> ? Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted December 10, 2007 Share Posted December 10, 2007 He means put your code inside code tags (while posting you will see a # icon) use that... And about your code... you need to display the image when the user presses the submit button, you are now using that GD function when the page loads, I have modified your code... check this now <?php ### when the user presses the submit button then use gd functions... if (isset($_POST['submit'])) { //loads image?? $im = imagecreatefrompng("background.png"); //defines text color $textcolor = imagecolorallocate($im, 255, 255, 255); // write the string at the top left ?? imagestring($im, 5, 0, 0, $_POST['text'], $textcolor); //outputs the image header("Content-Type: image/png"); imagepng($im); imagedestroy($im); } ?> <html> <head> <meta name="author" content="Rexcel Cariaga"> <link href="xampp.css" rel="stylesheet" type="text/css"> <title></title> </head> <body> <img src="background.png"> <form name="ff" action="delete.php" method="post"> <table width="294" border="0"> <tr> <td width="124"></td> <td width="160"></td> </tr> <tr> <td>Name Of Seller</td> <td><input type="text" name="text" size="25"></td> </tr> <tr> <td><p>Contact Number</p> </td> <td><label> <input name="contact" type="text" id="contact" size="25"> </label></td> </tr> <tr> <td>Product Name</td> <td><label> <input name="product" type="text" id="product" size="25"> </label></td> </tr> <tr> <td>Description</td> <td><label> <textarea name="description" cols="19" id="description"></textarea> </label></td> </tr> <tr> <td>Price</td> <td><label> <input name="price" type="text" id="price" size="25"> </label></td> </tr> <tr> <td> </td> <td><center><input type="submit" value="Submit"></center></td> </tr> </table> </form> <p> </body> </html> Quote Link to comment Share on other sites More sharing options...
~n[EO]n~ Posted December 10, 2007 Share Posted December 10, 2007 This is the working one... please check, hope you get the idea... <?php ### when the user presses the submti button then use gd functions... if (isset($_POST['submit'])) { header("Content-type: image/png"); $name = $_POST['text']; # get value for name... $contact = $_POST['contact']; # get value for contact... $product = $_POST['product']; # get value for product... $price = $_POST['price']; # get value for price... $description = $_POST['description']; # get value for price... $im = imagecreatefrompng("background.png"); $white = imagecolorallocate($im, 255, 255, 255); # this is for product imagestring($im, 5, 190, 20, $product, $white); # this is for description... imagestring($im, 5, 10, 80, $description, $white); # this is for name imagestring($im, 5, 300, 300, $name, $white); # this is for contact address imagestring($im, 5, 300, 320, $contact, $white); # this is for price imagestring($im, 5, 370, 80, $price, $white); imagepng($im); imagedestroy($im); } ?> <html> <head> <meta name="author" content="Rexcel Cariaga"> <link href="xampp.css" rel="stylesheet" type="text/css"> <title></title> </head> <body> <form name="ff" action="delete.php" method="post"> <table width="294" border="0"> <tr> <td width="124"></td> <td width="160"></td> </tr> <tr> <td>Name Of Seller</td> <td><input type="text" name="text" size="25"></td> </tr> <tr> <td><p>Contact Number</p> </td> <td><label> <input name="contact" type="text" id="contact" size="25"> </label></td> </tr> <tr> <td>Product Name</td> <td><label> <input name="product" type="text" id="product" size="25"> </label></td> </tr> <tr> <td>Description</td> <td><label> <textarea name="description" cols="19" id="description"></textarea> </label></td> </tr> <tr> <td>Price</td> <td><label> <input name="price" type="text" id="price" size="25"> </label></td> </tr> <tr> <td> </td> <td><center><input type="submit" name="submit" value="submit"></center></td> </tr> </table> </form> <p> </body> </html> Quote Link to comment Share on other sites More sharing options...
yekis Posted December 11, 2007 Author Share Posted December 11, 2007 thanks a lot!!! got the script and it works!!! Quote Link to comment Share on other sites More sharing options...
yekis Posted December 11, 2007 Author Share Posted December 11, 2007 hi..another question..same project but another problem aroused..regarding word wrapping...heh... this is my original code for the "description" field and it works... ORIGINAL CODE -------------------------------------------------------------------- # this is for description... imagettftext($im, 18, 0, 10, 90, $white, $font, $description); -------------------------------------------------------------------- .... nonetheless when i try to word wrap the string (see code below), i still get one line of text..it doesn't go to the next line..pls..help..tnx REVISED CODE -------------------------------------------------------------------- # this is for description... //displays string and defines its position imagettftext($im, 18, 0, 10, 90, $white, $font, $description); $text = $imagettftext; //wraps string??? $newtext = $newtext = wordwrap($text, 20, "<br />\n"); echo $newtext; ## is this needed?? --------------------------------------------------- hoping for your reply...tnx //displays string and defines its position imagettftext($im, 18, 0, 10, 90, $white, $font, $description); $text = $imagettftext; //wraps string??? $newtext = $newtext = wordwrap($text, 20, "<br />\n"); echo $newtext; ## is this needed?? Quote Link to comment Share on other sites More sharing options...
yekis Posted December 11, 2007 Author Share Posted December 11, 2007 no need to reply...already got the code..tnx a lot guys!!! Quote Link to comment 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.