Results 1 to 5 of 5

Thread: PHP Validation

  1. #1
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default PHP Validation

    My form below is written in Javascript... *this is to prevent people without Javascript installed from uploading files *because they could be fake or worse*, plus I wanted to experiment with javascript... so thats why its all in document.write form... sorry but its also a little easier to write.

    Code:
    document.write("<div class='pureadd'>")
    document.write("<form action='send.php' method='post' class='form'>")
    
    document.write("<h1>Upload Your File</h1>")
    document.write("<fieldset><legend>Step 1</legend>")
    document.write("Only put what is true, if you put any fake information your upload will be ignored")
    document.write("<br>Your First Name:")
    document.write("<br><input type='text' name='FName'  class='input'/>")
    document.write("<br>")
    document.write("<br>Your Last Name:")
    document.write("<br><input type='text' name='LName'  class='input'/>")
    document.write("<br>")
    document.write("<br>Your Age:")
    document.write("<br><input type='text' name='Age'  class='input'/>")
    document.write("<br>")
    document.write("<br>Your Email Address:")
    document.write("<br><input type='text' name='EmailAddress'  class='input'/>")
    document.write("</fieldset>")
    
    document.write("<fieldset><legend>Step 2</legend>")
    document.write("<br>Your File's Title:")
    document.write("<br><input type='text' name='Title'  class='input'/>")
    document.write("<br><p>This is what the title of the video is going to be called, ")
    document.write("<br>Is your Video Amazing or Funny?")
    document.write("<br><input type='checkbox' value='Amazing' name='Video Type'/> My Video is Amazing. ")
    document.write("<br><input type='checkbox' value='Funny' name='Video Type'/> My Video is Funny. ")
    document.write("<br><input type='checkbox' value='Unknown' name='Video Type'/> I have no clue. ")
    document.write("</fieldset>")
    document.write("<fieldset><legend>Step 3</legend>")
    var d = new Date()
    document.write("<br>Time Page Loaded:")
    document.write("<br><input type='text' value='"+Date()+"' name='time' readonly='true' class='input'>")
    document.write("<br>")
    document.write("<br>By submitting your file you agree with with our Terms of Service, if you haven't read them, please read them before submitting your file.")
    document.write("</fieldset>")
    document.write("<fieldset><legend>Step 4</legend>")
    document.write("<br>Select your file type:")
    document.write("<br><input type='checkbox' value='Video' Name='Filetype'> Video File")
    document.write("<br><input type='checkbox' value='Picture' Name='Filetype'> Picture File")
    document.write("<br><input type='checkbox' value='Audio' Name='Filetype'> Audio File")
    document.write("<br>")
    document.write("<br>Upload Your File:")
    document.write("<br><input type='file' value='' name='FILENAME' id='file'/>")
    document.write("<br>")
    Now thats the whole form... theres only a couple of things I want to validate using PHP.
    First one is going to be to make sure everythings not blank...
    Second one could it deal with the age... because I don't want people sending in 999 as an age, so is there a way to put a max limit like (110) because I highly doubt the oldest person in the world can submit files, I bet he/she has other things todo.
    Third the last one is the
    Code:
    document.write("<br><input type='file' value='' name='FILENAME' id='file'/>")
    document.write("<br>")
    is there a way inorder to get this to filter out certain files... I don't know PHP, and my server is holding itself hostage and preventing me from viewing PHP codes... so if you could check before you post it that would be awesome


    THANKS TO ALL!
    Last edited by thetestingsite; 08-24-2007 at 10:34 PM.

  2. #2
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    *this is to prevent people without Javascript installed from uploading files *because they could be fake or worse*
    And you imagine that this is going to stop them how exactly?
    <br>Your File's Title:
    This is an abuse of the <br> element. Separate the fields by grouping them in elements.
    <input type='checkbox' value='Amazing' name='Video Type'/>
    You're not using XHTML, so don't use XHTML-style closing syntax (and if you were using XHTML, the <br> would need to be closed as well and the document.write()s wouldn't work).

    The PHP code to check if something is empty is:
    Code:
    if(empty($_POST['age']))
    To check if "age" is greater than 110:
    Code:
    if($_POST['age'] + 0 > 110)
    is there a way inorder to get this to filter out certain files...
    What files?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  3. #3
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    Ok, talk in english...

    I want to have a filter on what type of files are uploaded. Like i want only mpg, mpeg, avi, and mov files to be uploaded, if it isn't the form isn't sent...

  4. #4
    Join Date
    Jan 2007
    Location
    Davenport, Iowa
    Posts
    2,385
    Thanks
    100
    Thanked 113 Times in 111 Posts

    Default

    Shouldn't this be in the javascript thread? I don't really know javascript, but there is a thread that was recently brought up that deals with the uploading of specific types of files like images and movies based on the file extension.

    Link to the thread.
    Last edited by james438; 08-25-2007 at 09:29 AM.

  5. #5
    Join Date
    Jan 2007
    Location
    The stage
    Posts
    568
    Thanks
    23
    Thanked 6 Times in 6 Posts

    Default

    It was in Javascript but then I was told PHP would be a better more secure way todo this...

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
  •