SitePoint Sponsor

User Tag List

Results 1 to 3 of 3

Thread: Help with form

  1. #1
    SitePoint Enthusiast
    Join Date
    Jul 2002
    Posts
    84
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Help with form

    Hi,

    For one of my form entries I need the user to enter in exactly 12 variable/characters. How do I limit it so that if a user types in 11, 13 ect... that it prompts you to re-enter correctly as 12 variable/characters.

    Also, since these numbers need to be unique how would you do a check if it is in the db already and prompt you for a different varibale/character set?

    Elfmuse

  2. #2
    SitePoint Wizard mark_W's Avatar
    Join Date
    Mar 2004
    Location
    West Midlands, United Kingdom
    Posts
    2,631
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    you can use the maxlength form attribute on the HTML side!

    <input type="text" name="whatever" maxlength="12">

    or you could check the length using php by using the strlen() function!

    http://www.php.net/strlen

    Mark.

  3. #3
    SitePoint Addict
    Join Date
    Nov 2004
    Location
    Ukraine
    Posts
    245
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    But you must know, that you must also do server side check
    if(length($_POST["var"]) > 12)die("hack detected");
    Becouse somebody may simulate post to your script (by editing form/creating fфлу request) and it may be dangerous(hack possibility)


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
  •