Re: Displaying Form Errors

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On 3/2/06, Paul Goepfert <paul.goepfert@xxxxxxxxx> wrote:
> Hello all,
>
> I am building a web page and I don't know how to display the errors
> that the user may enter.  OK this is how I have my web page setup:
>
> I first do a isset check on $submit.  And I am not sure about this.  I
> believe that this variable is set when i click on the submit button.
> I don't have a $submit variable assigned to anything in my web page.
> What I would like is to have $submit assigned to the submit button.
> How do I do that?
>
> In the if block I do my validation of the web form.  In the else block
> I have the contents of the page.
>
> I have posted this question before and I got some good pointers on how
> I should go about doing my validation but I have not yet figured out
> how to display the errors on the page.  Could someone help me with
> that.  I am doing the validation on the same page as the web page.  I
> don't forward to a new page to do the validation.
>
> Thanks
>
> Paul
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
>
>
>

post it to itself ie - action="submit.php", and your data will end up
in $_request["name1"];
validate these, if an error occurs, I would add class="error" to the
html element, and use css to display it as red. And dump an error
message above the form, make sure you validate all fields before
breaking out, track them in an $errors = array(); ...makes for a
better user experience.

Typically, there is a hidden field called "run" or "mode" indicating
what flow you're in.

<form action="controller.php" method="post" id="login">
    <input type="hidden" name="run" value="login"/>
    <fieldset>
      <legend>Login</legend>
    <label>Username:</label> <input type="text" name="username"/>
    <label>Password:</label> <input type="password" name="password"/>
    </fieldset>
</form>


--
Anthony Ettinger
Signature: http://chovy.dyndns.org/hcard.html

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux