Log in

View Full Version : PHP Validation



Rockonmetal
08-24-2007, 10:04 PM
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.


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

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!

Twey
08-25-2007, 12:45 AM
*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:
if(empty($_POST['age']))To check if "age" is greater than 110:
if($_POST['age'] + 0 > 110)
is there a way inorder to get this to filter out certain files...What files?

Rockonmetal
08-25-2007, 01:58 AM
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...

james438
08-25-2007, 09:17 AM
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. (http://www.dynamicdrive.com/forums/showthread.php?t=23741)

Rockonmetal
08-25-2007, 02:28 PM
It was in Javascript but then I was told PHP would be a better more secure way todo this...