SitePoint Sponsor

User Tag List

Results 1 to 4 of 4
  1. #1
    SitePoint Addict
    Join Date
    Aug 2010
    Posts
    349
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    forms: .php or .html?

    I'm a bit confused, I found some tutorials where you create an HTML file with the form mark up and link to a php file to make the form work. And I've seen some tuts that have you just write up a .php file and do the markup with in it.

    What's the difference and is one better than the other?

  2. #2
    . shoooo... silver trophy logic_earth's Avatar
    Join Date
    Oct 2005
    Location
    CA
    Posts
    9,013
    Mentioned
    8 Post(s)
    Tagged
    0 Thread(s)
    It is the same thing no matter how you slice it. They achieve the same result using different methods.
    Logic without the fatal effects.
    All code snippets are licensed under WTFPL.


  3. #3
    SitePoint Member
    Join Date
    Feb 2011
    Location
    Boston, MA
    Posts
    5
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    They can achieve the same result. However, the single PHP can be more flexible, such as for validation. You'll be able to add a custom error message or add error CSS classes to controls based on user input. All of these would result in a friendlier user-interface.

  4. #4
    SitePoint Enthusiast Ultimater's Avatar
    Join Date
    Jun 2005
    Location
    Los Angeles
    Posts
    94
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Forms built in PHP allow you more control over how the page renders in regard to the user displaying the form as you can track the user with sessions and/or cookies. That way when the form is submit, you can have a captcha on it to prevent spam. Its also possible to create a captcha on an HTML-genereated form that links to a PHP-script for generating the captcha image and sets a cookie when it genereates, then when the form is submit, PHP can check for the cookie to decide which captcha was given to you to solve. If the user had cookies disabled, HTML-generated forms would completely fall-appart without some sort of JavaScript or a way to communicate with the server such as Flash etc. PHP can accomplish this task (captchas) via sessions even with JavaScript and cookies disabled.

    Beyond captchas, PHP can add in things you'd expect from server-side includes such as the current-time, or an include to your menu-bar html so you only have to edit one file to control the menu-bar on all the pages on your site which render one etc etc...
    If your site uses a lot of PHP, take these forums on sitepoint for instance, PHP also allows you access to a database so the submitted form can be further-controlled to add an entry to a database to interact with other users on the net... etc.
    Ultimater

    GuestBook: View Sign


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •