HTML
  Home arrow HTML arrow Page 8 - Submitting a Form Using an Image Tag
Dev Articles Forums 
ADO.NET  
Apache  
ASP  
ASP.NET  
C#  
C++  
ColdFusion  
COM/COM+  
Delphi-Kylix  
Design Usability  
Development Cycles  
DHTML  
Embedded Tools  
Flash  
Graphic Design  
HTML  
IIS  
Interviews  
Java  
JavaScript  
MySQL  
Oracle  
Photoshop  
PHP  
Reviews  
Ruby-on-Rails  
SQL  
SQL Server  
Style Sheets  
VB.Net  
Visual Basic  
Web Authoring  
Web Services  
Web Standards  
XML  
Mobile Linux 
App Generation ROI 
IBM® developerWorks 
Sun Developer Network 
Weekly Newsletter
 
Developer Updates  
Free Website Content 
 RSS  Articles
 RSS  Forums
 RSS  All Feeds
Write For Us Get Paid 
Request Media Kit
Contact Us 
Site Map 
Privacy Policy 
Support 
 USERNAME
 
 PASSWORD
 
 
  >>> SIGN UP!  
  Lost Password? 
HTML

Submitting a Form Using an Image Tag
By: Chris Root
  • Search For More Articles!
  • Disclaimer
  • Author Terms
  • Rating: 5 stars5 stars5 stars5 stars5 stars / 18
    2005-04-18

    Table of Contents:
  • Submitting a Form Using an Image Tag
  • Submitting a Form
  • Processing the Form
  • The Server Side Code
  • GD Methods
  • Handling the Name
  • The TextBox Class
  • From the Top

  • Rate this Article: Poor Best 
      ADD THIS ARTICLE TO:
      Del.ici.ous Digg
      Blink Simpy
      Google Spurl
      Y! MyWeb Furl
    Email Me Similar Content When Posted
    Add Developer Shed Article Feed To Your Site
    Email Article To Friend
    Print Version Of Article
    PDF Version Of Article
     
     
    ADVERTISEMENT


    Submitting a Form Using an Image Tag - From the Top


    (Page 8 of 8 )

    We actually jumped ahead in the code in order to explain what this application needed to accomplish and how it would go about it. Now let's look at it in order of execution.

    //load the background image

    $im = imagecreatefrompng("images/confirm.png");

    $textColor = imagecolorallocate($im,255,255,255);//allocate white

    //get text dimensions

    $nameArr = handleName($fontSize,$fontPath,$im,$str);

    $vPos = getVerticalPosition($im);//get vertical coordinate for all text

    for($i = 0;$i < count($nameArr);$i++)

    {

           imagettftext($im,$fontSize,0,$nameArr[$i]->hpos,$vPos,

           $textColor,$fontPath,$nameArr[$i]->textStr);

           $vPos = $vPos + $nameArr[$i]->h;

    }

    header("Content-type: image/png");

    imagepng($im);

    imagedestroy($im);

    Once we have all the coordinates needed to place the text, it's time to actually write it to the image. The imagettftext function is used for each text box. Arguments are as mentioned before: image resource, the font size, the angle, the horizontal coordinate, the vertical position, the text color that we allocated, the font and the text string. Notice that at the end of each loop iteration, the height of the current text block is added to the vertical position. This will put the next text block below the previous.

    Once all the text is placed, the HTTP header is sent, announcing that we are sending an image of type png. The imagepng() function then sends the image, and we use imagedestroy() to close the stream.

    Conclusion

    As you can see, the hardest part of all this was working with the text, and this example does not show what to do with the email address or entering the user in the contest, as your use of this form submission technique will depend on the situation. How the server side code works will vary depending on what platform you are using.

    You now have an understanding of how an image tag can be used to submit a form and create a better user experience for the visitors of your site. For more information on GD and PHP, take a look at the PHP documentation at php.net


    DISCLAIMER: The content provided in this article is not warranted or guaranteed by Developer Shed, Inc. The content provided is intended for entertainment and/or educational purposes in order to introduce to the reader key ideas, concepts, and/or product reviews. As such it is incumbent upon the reader to employ real-world tactics for security and implementation of best practices. We are not liable for any negative consequences that may result from implementing any information covered in our articles or tutorials. If this is a hardware review, it is not recommended to open and/or modify your hardware.

       · That needs JavaScript to submit a form?At least have a server side validation and...
       · I specifically left validation up to the reader as validation is a topic all by...
       · Accessibility means that you make sure anyone can use the application regardless of...
       · I did not mean to imply that I ignore accessibility in my real projects. I always...
       · I've been using a hidden IFrame to handle form submissions - the web page shunts all...
       · For 'Anonymous Loozah #1'there are many ways to submit forms on the web... some...
     

    HTML ARTICLES

    - Using a 3D HTML Table as a Recordset
    - Building a 3D HTML Table
    - Maximizing and Restoring HTML Images: Layer ...
    - Completing Construction of a Database Form w...
    - Maximizing and Restoring Images in a Tabular...
    - Building the Recordset for an HTML Database ...
    - Laying Out a Database Form with HTML
    - Tabular Database Form Functions with HTML
    - Tabular Database Forms with HTML
    - Using the Find Functions for HTML Database F...
    - Sorting for Database Forms with HTML
    - Edit and Other Database Form Functions with ...
    - More Database Form Functions with HTML
    - Database Form Functions with HTML
    - Using the HTML Table Element as a Recordset






    © 2003-2008 by Developer Shed. All rights reserved. DS Cluster 3 hosted by Hostway
    Stay green...Green IT