Server-Side Form Validation

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • TristaSD

    Server-Side Form Validation

    Hi,

    I know, I know, there's a ton of form validation questions already in
    this group. However, I can't seem to make sense of any of the posts -
    none go into detail.

    All I need is to validate my form with 'post' method on the server
    because my terminals' JavaScript abilities are questionable.

    So far I've created a global error flag that gets raised whenever a
    form field's value is invalid. However, though that accomplishes the
    task of validating the form, it DELETES all information from ALL form
    fields.

    I know that in .net it's a built-in feature, but in php I'd have to
    write some, what do you call it ... ah, yes ... BOILER PLATE code.

    Any way to do that? The forms must be validated server-side. Thank
    you!

  • Gordon Burditt

    #2
    Re: Server-Side Form Validation

    >All I need is to validate my form with 'post' method on the server[color=blue]
    >because my terminals' JavaScript abilities are questionable.[/color]

    JavaScript abilities are ALWAYS questionable because it can be
    turned off, and it's not present in programs like telnet and CURL
    that can be used in place of a browser. Input validation for
    security or data-integrity should be done on the server, and possibly
    also in JavaScript also for user-friendliness and immediate
    notification of an error.
    [color=blue]
    >So far I've created a global error flag that gets raised whenever a
    >form field's value is invalid. However, though that accomplishes the
    >task of validating the form, it DELETES all information from ALL form
    >fields.[/color]

    When you re-paint the form, you can output HTML to put the submitted
    values (or just the ones that pass validation) into the new copy
    of the form (VALUE="...").

    Gordon L. Burditt

    Comment

    • TristaSD

      #3
      Re: Server-Side Form Validation

      Thanks. I suspected I'd have to do that. Any way to streamline the
      process and re-use the code for other forms?

      Comment

      • Alan Little

        #4
        Re: Server-Side Form Validation

        Carved in mystic runes upon the very living rock, the last words of
        TristaSD of comp.lang.php make plain:
        [color=blue]
        > Thanks. I suspected I'd have to do that. Any way to streamline the
        > process and re-use the code for other forms?[/color]

        Check out Phorm, either to use or to get ideas of your own. It has pretty
        thorough data validation capabilities, with form recycling. Just bear in
        mind that I've learned a lot since I wrote that section, so there's some
        room for improvement :)

        --
        Alan Little
        Phorm PHP Form Processor

        Comment

        Working...