help : security in form fields with php

Discussion in 'Security' started by Mr.only, Jan 17, 2011.

  1. #1
    i have form .. and insid it field name pub

    it use fo adsense publisher id ..
    like this
    
    <FORM action="thanx.php" method="post">
         Name       :<INPUT size="40" name="name">
         pubisher id:<INPUT size="40" name="pub" >
                         <INPUT type="submit" value="send" name="send">
    </FORM>
    
    Code (markup):
    and How can i make security for it ..because some users post their publishr id wrong ..not full
    and
    some users post in the field "text" not numbers ..
    so winder if i can do something in the form to tell my users that is wrong publisher id
    and it must be 16 number .. using php or jave but dont leave the form if it wrong ..
     
    Mr.only, Jan 17, 2011 IP
  2. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #2
    zacharooni, Jan 18, 2011 IP
  3. Alex Roxon

    Alex Roxon Active Member

    Messages:
    424
    Likes Received:
    11
    Best Answers:
    7
    Trophy Points:
    80
    #3
    Basic security tip: never rely solely on client side validation. Back it up with validation serverside, i.e. upon submission use PHP to make sure the user data is formatted exactly as you would like it.
     
    Alex Roxon, Jan 19, 2011 IP
  4. zacharooni

    zacharooni Well-Known Member

    Messages:
    346
    Likes Received:
    20
    Best Answers:
    4
    Trophy Points:
    120
    #4
    Alex, absolutely true. However, it's going to be much more involved, possibly involving $_POST or $_SESSION variables as default values, so that they never 'leave the form', even if they actually do.
     
    zacharooni, Jan 19, 2011 IP
  5. Mr.only

    Mr.only Peon

    Messages:
    37
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #5
    thank you all
     
    Mr.only, Jan 20, 2011 IP