uploading more than what is allowed

Discussion in 'PHP' started by oo7ml, Sep 23, 2007.

  1. #1
    I have a section on my form called "Personal Details" - the max length is set to 250. My database field is set to varchar(250). what happens if some how a user tries to upload 260 characters. What would happen (lets say that i have no JS or php validation... the only validation is the maxlenght in the form) so what would happen
     
    oo7ml, Sep 23, 2007 IP
  2. krt

    krt Well-Known Member

    Messages:
    829
    Likes Received:
    38
    Best Answers:
    0
    Trophy Points:
    120
    #2
    Depends. It will most likely be truncated by your database system.
     
    krt, Sep 23, 2007 IP
  3. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #3
    You can check the length of the data submitted using strlen() eg
    if (strlen($_POST['info'] <= 250))
     
    matthewrobertbell, Sep 23, 2007 IP
  4. bubbles19518

    bubbles19518 Peon

    Messages:
    73
    Likes Received:
    1
    Best Answers:
    0
    Trophy Points:
    0
    #4
    you mean:
    if (strlen($_POST['info']) <= 250)
     
    bubbles19518, Sep 23, 2007 IP
  5. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #5
    Yes, i do, that's what not paying attention gets you:|
     
    matthewrobertbell, Sep 23, 2007 IP
  6. webrickco

    webrickco Active Member

    Messages:
    268
    Likes Received:
    4
    Best Answers:
    0
    Trophy Points:
    60
    #6
    If the maxlength of the field is set to 250, how could you receive longer length on the server anyway?
     
    webrickco, Sep 24, 2007 IP
  7. matthewrobertbell

    matthewrobertbell Peon

    Messages:
    781
    Likes Received:
    35
    Best Answers:
    0
    Trophy Points:
    0
    #7
    <form method="post" action="http://yourserver.com/yourscript.php">
    <input type="text" name="somename" length="251" />
    </form>
    Code (markup):
    Never trust user input ;)
     
    matthewrobertbell, Sep 24, 2007 IP