Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3

Thread: Form help

  1. #1
    New Coder
    Join Date
    Oct 2009
    Location
    Walsall, UK
    Posts
    38
    Thanks
    7
    Thanked 0 Times in 0 Posts

    Form help

    I've used PHP to code an account registration system for my website, and it works perfectly. However, on the form where users enter their account information to be put into the database, I want to have a Confirm Password box that is compared to the Password box, and gives the user an error if they don't match. Also, I want the user to be unable to submit the form with blank entries.

    This is my form at the moment:

    Code:
    <TABLE><TR><TD>
    <form method="post" action="register.php">
    Name<br>
    <input type="text" name="username">
    <br></TD></TR><TR><TD>
    Password<br>
    <input type="text" name="password">
    <br></TD></TR><TR><TD>
    <input type="submit" name="Submit" value="Submit">
    </form>
    </TD></TR></TABLE>
    I'm not sure if it's HTML I need for this, but any help would be great, thanks.

  • #2
    Senior Coder Rowsdower!'s Avatar
    Join Date
    Oct 2008
    Location
    Some say it's everything.
    Posts
    2,027
    Thanks
    5
    Thanked 397 Times in 390 Posts
    You need javascript for this on the client side but - VERY IMPORTANTLY - remember that you need to have the same checks (and then some) on the server-side to clean and validate data. Javascript can be disabled and/or modified by the user so you can't trust that it will take complete care of your form data. A user with something as simple as firebug can manipulate your HTML/javascript on their side and submit your form with extra fields that they entered. You also have to consider what happens if someone submits data to your form from another site as part of a malicious attack. The possibilities are endless but there are basic steps you can take to curtail the obvious ones.

    Always always ALWAYS validate data server-side before storing or processing that data.

    With that said, it's still a good idea to validate client-side first to avoid wasted bandwidth and server resources when legitimate users enter data that is obviously incorrect. So by all means, please do pursue a javascript solution for your form checking. Google can be a very good friend for this.
    The object of opening the mind, as of opening the mouth, is to shut it again on something solid. G.K. Chesterton
    See Mediocrity in its Infancy
    It's usually a good idea to start out with this at the VERY TOP of your CSS: * {border:0;margin:0;padding:0;}
    Seek and you shall find... basically:
    validate your markup | view your page cross-browser/cross-platform | free web tutorials | free hosting

  • #3
    New Coder
    Join Date
    Oct 2009
    Location
    Walsall, UK
    Posts
    38
    Thanks
    7
    Thanked 0 Times in 0 Posts
    Thanks for the reply, but I've already sorted it. I did IF statements for comparing Password and Confirm Password boxes, not allowing the user to submit blank fields, and to check the database if the username has already been taken.

    I don't like javascript lol.


  •  

    Posting Permissions

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