Jump to content


Photo

advice on php powered forms


  • Please log in to reply
9 replies to this topic

#1 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 June 2006 - 02:05 PM

I have never started with this before, so I wanted to clarify a few things first, before I get too confused.
In order for me to prepare the form, to start getting information to php I added the

enctype="multipart/form-data"
Ok I know that was needed to prepare the form, now on the form file field, before it you are supposed to input something along the lines of
<input type="hidden" name="MAX_FILE_SIZE" value="30000" />
This would go above the file form field. Now here is my entire form right now, but I had a few questions, I will be wading through it, but after I get done I will have tripled my php knowledge, I am learning so fast lately, I do everything I can on my own and seek help when I get stuck.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<link rel="stylesheet" type="text/css" href="funnyemails.css" />
<meta name="Description" content="If you have a funny email, feel free to put it into our database, to send to all the people signed up to recieve funny emails" />
<meta name="Keywords" content="funny, emails, email, fowards, joke, video, song, poem, picture, yellow pages, services" /> <!-- Search engine preparation -->
<!-- If you have a funny email, feel free to put it into our database, to send to all the people signed up to recieve funny emails -->
<!-- funny, emails, email, fowards, joke, video, song, poem, picture, yellow pages, services -->
<!-- Above comment tags accommodate search engines that do not pick up Meta Tags -->
<meta name="author" content="A service of Yellow Pages Online" />
<title>Funny Email Forwards</title>
</head>
<body>
<div id="header">
<!-- Begin top area, with logo, and text below it -->
<img src="images/logo.gif" alt="Logo" /><br />
<p id="headertext">The web's directory of funny Email forwards<br />
<a href="http://www.yellowpagesservices.com" id="headerbelow" target="_blank"><img src="images/ypol.gif" alt="The Yellow Pages" /></a></p>
</div>
<!-- End top area -->
<!-- Begin middle area, this is the place that contains masses of information, it has the 2 forms.  The search form, and the add something form, they both go to different pages, and have different functions.  I wrapped them all inside of other divs, to allow for maximum flexibility, for future designs or re-designs -->
<div id="containleftright">
<div id="leftdiv">
<h3>Add Something Funny:</h3>
<form name="submitinformation" id="submitinformation" enctype="multipart/form-data" action="whatever.php" method="post">
<label for="type">What Type of Funny is it:</label>
<select tabindex="1"name="type" id="type">
<option>Video</option>
<option>Picture</option>
<option selected="selected">Joke</option>
<option>Song</option>
<option>Poem</option>
<option>Story</option>
</select><br />
<label for="name">Name the Funny:</label>
<input tabindex="2" name="name" id="name" type="text" maxlength="80" /><br />
<label for="keywords"><a href="keywords.htm">Keywords:</a></label>
<input tabindex="3" name="keywords" id="keywords" type="text" maxlength="80" /><br />
<label for="file">Upload your file here:</label>
<input tabindex="4" name="file" id="file" type="file" /><br />
<input tabindex="5" name="submit" id="submit" type="submit" value="Do It!" />
</form>
</div>
<div id="middlediv">
<p>OR</p>
</div>
<div id="rightdiv">
<h3>Search For Something Funny:</h3>
<form name="searchform" id="searchform" action="something.php" method="get">
<label for="searchfield">What would you like to search for?</label><br />
<input tabindex="6" name="searchfield" id="searchfield" type="text" size="33" maxlength="80" /><br />
<input tabindex="7" name="search" id="search" type="submit" value="Do It!" />
</form>
</div>
</div>
<!-- End middle area -->
<!-- begin lower areas, This areas list links to other areas of the site, that contain the newest additions to the database -->
<div id="wrapmiddle">
<h3 id="directory">Directory of Listings:</h3>
<div id="upperleft">
<h3 class="specialheader">VIDEOS</h3>
<ul>
<li>Link Number one will go here</li>
<li>Link Number two will go here</li>
<li>Link Number three will go here</li>
</ul>
</div>
<div id="uppermid">
<h3 class="specialheader">PICTURES</h3>
<ul>
<li>Link Number one will go here</li>
<li>Link Number two will go here</li>
<li>Link Number three will go here</li>
</ul>
</div>
<div id="upperright">
<h3 class="specialheader">JOKES</h3>
<ul>
<li>Link Number one will go here</li>
<li>Link Number two will go here</li>
<li>Link Number three will go here</li>
</ul>
</div>
<div id="lowerleft">
<h3 class="specialheader">SONG</h3>
<ul>
<li>Link Number one will go here</li>
<li>Link Number two will go here</li>
<li>Link Number three will go here</li>
</ul>
</div>
<div id="lowermid">
<h3 class="specialheader">POEM</h3>
<ul>
<li>Link Number one will go here</li>
<li>Link Number two will go here</li>
<li>Link Number three will go here</li>
</ul>
</div>
<div id="lowerright">
<h3 class="specialheader">STORY</h3>
<ul>
<li>Link Number one will go here</li>
<li>Link Number two will go here</li>
<li>Link Number three will go here</li>
</ul>
</div>
</div>
<!-- end area near bottom -->
<!-- Bottom area, this area at the bottom contains copyright information and teh link list, I set it up in a list and ran it sideways, and did some adjusting to margin/padding, so it should work perfectly in teh future if new links need to be added, they should all fall into place quite easily -->
<div id="bottomwrap">
<ul id="bottomnav">
<li><a href="aboutfunnyemails.htm" tabindex="8" title="The About Page">About FunnyEmailForwards.com</a></li>
<li><a href="signup.php" tabindex="9" title="Sign up for the newsletter">Sign Up</a></li>
<li><a href="contactus.php" tabindex="10" title="Contact Us">Contact Us</a></li>
</ul>
<p>Copyright 2000-2006 FunnyEmailFowards.com a service of YellowPages Online.  All Rights Reserved.</p>
</div>
<!-- End bottom area -->
</body>
</html>

The form I am currently focusing on is the one accepting files. What I need to find out, what is the average recommended maximum file size. I also need to know a few things.

When I first start this I know how to accept the form, I need to figure out, what php functions should I use to validate file types, the extensions. And what kind of file types should I accept into the database, and not accept into the database, I need to figure this out,
Ok as for the database
I was thinking for the table to have these fields, do you think this will cover everything I was wanting, this is hard for me, because I have to allow the owner(ceo) of the company to recieve an email and be able to approve/deny any material inserted into the database. I don't know how to work all of this yet.

So I create a table I would have
file
name
keywords
umm file I guess
How do I set the table(I know how to create one and everything now) is there anything I should take into consideration, like that. Do I need to worry about viruses, or find a way to validate for them, so far I know what i need to do,
validate the fields as always, validate and screen out specific unwanted file types(extensions), I need it to enter it into the database, under a specific field, and have the email be sent with a link to another page allowing him to approve or deny, what do I do with the database to allow it to not show up until he approves it, and I will have to do it with all of these fields. Another thing I know I have to take into account is the keywords, are going to have to be something I use later when creating the query in the other form to search the information, is there anything special I need to take into account for that. The other question now was I have to do this right, I already know I will end up rewriting the script probably 4-5 times before it's done, I did with the other one, but now I have a broader deeper understanding of php/mysql because of it. The last question I wanted to ask, with my subscribe unsubscribe one I was doing earlier, I had to do 2 scripts one for subscribe and one for unsubscribe, 1 to handle each part. With this do I need 6 different script sections one to handle each file type field like
1 for
isset($_POST['joke']
and all the 5 others, one for each type of field they can choose, I am just looking for guidance advice, direction or anything, thanks.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#2 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 June 2006 - 02:17 PM

Honestly, I'd suggest you put this in the freelancing forum and offer someone money to do it for you. That will save your time and energy. You can learn all you need from reviewing somebody's complete, commented, functional code ... or you could use Google to find any one of a zillion php scripts that allow for uploads and modify it to suit.
Legend has it that reading the manual never killed anyone.
My site

#3 poirot

poirot
  • Members
  • PipPipPip
  • Advanced Member
  • 646 posts
  • LocationAustin, TX

Posted 14 June 2006 - 02:23 PM

You can check the extension using:

$file = 'index.php';
$ext = substr($file, strrpos($file, '.'));
// $ext is .php

Note that this gives not the real extension, but only the file's extension. In order to know what the file actually is, you'd need to check its headers, and that's not easy.

To figure out what are the sizes and extensions you should allow or deny is up to you.

You can store this in a temporary table (file name, hash) and send an email to the CEO with a "approval link". Once it is clicked the file is approved or rejected, then proceed accordingly.
~ D Kuang

#4 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 June 2006 - 02:36 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Honestly, I'd suggest you put this in the freelancing forum and offer someone money to do it for you. That will save your time and energy. You can learn all you need from reviewing somebody's complete, commented, functional code ... or you could use Google to find any one of a zillion php scripts that allow for uploads and modify it to suit.[/quote]
I am a programmer not a beginner. I am trying to get help with advice. I know what you mean, but that's what I am doing for a living web site design/coding/programming/other.
I have to learn php, I just come here for occassional clarification or help, and try to help other people when I can. I checked all of these things on google, and everywhere else, found what I can and came here seeking some clarification and guidance. I don't want to hire someone else, because I would probably think the way they did it wouldn't be the way I wanted it done, that is why I am trying to learn, I created the scripts for subscribing and unsubscribing, and set that up, now I am trying to tackle this.

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]Note that this gives not the real extension, but only the file's extension. In order to know what the file actually is, you'd need to check its headers, and that's not easy.[/quote]
I am digging through the manual and google now, trying to find some ideas on creating some form of extension validation.


To figure out what are the sizes and extensions you should allow or deny is up to you.
I know, but I was trying to get some general ideas or opinions, on what other people sometimes use. For instance does mysql have a maximum limit, what do you use on your file forms.
Ex cetera

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]You can store this in a temporary table (file name, hash) and send an email to the CEO with a "approval link". Once it is clicked the file is approved or rejected, then proceed accordingly.[/quote]
The part I don't currently understand here is this.
I put it in the database.
Then I send him an email with a link to another page.
What is that page going to do, how do I get that page to reflect what form information was put into the form. This is the part that is confusing me, that I am trying to get in my head, before starting the programming.


------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#5 AndyB

AndyB
  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 14 June 2006 - 02:59 PM

[!--quoteo--][div class=\'quotetop\']QUOTE[/div][div class=\'quotemain\'][!--quotec--]I am a programmer not a beginner. I am trying to get help with advice. I know what you mean, but that's what I am doing for a living web site design/coding/programming/other.[/quote]
All I'm going to say is that your time is worth money, and 'saving' a few dollars by spending hours on this is counter-productive.

I know how to cut grass. I could spend an hour doing mine. I get the kid across the street to do it for $5 and save an hour of my time - which is worth a lot more than $5.
Legend has it that reading the manual never killed anyone.
My site

#6 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 June 2006 - 03:03 PM

Oh I see what you mean now, yes with that I will eventually possibly do that, I already figured out what I would do about that, but I want to learn first, I don't want to always get someone, I am pretty sure this specifically, is something if I knew how to do well enough, I could do within 2 hours, not even. right now it will take me 2-3 days but when I get better and faster, then I will be able to do more, any advice on this would be greatly appreciated.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.


#7 joquius

joquius
  • Members
  • PipPipPip
  • Advanced Member
  • 319 posts

Posted 14 June 2006 - 03:06 PM

[!--quoteo(post=383840:date=Jun 14 2006, 03:59 PM:name=AndyB)--][div class=\'quotetop\']QUOTE(AndyB @ Jun 14 2006, 03:59 PM) View Post[/div][div class=\'quotemain\'][!--quotec--]
All I'm going to say is that your time is worth money, and 'saving' a few dollars by spending hours on this is counter-productive.

I know how to cut grass. I could spend an hour doing mine. I get the kid across the street to do it for $5 and save an hour of my time - which is worth a lot more than $5.
[/quote]
slave labour. you should be ashamed.
wish my time was worth more than $5 an hour
z..z..z..z..z..z..z..z..

#8 Buyocat

Buyocat
  • Members
  • PipPipPip
  • Advanced Member
  • 267 posts

Posted 14 June 2006 - 03:48 PM

Alright, I'm not sure if I completely understood what you're looking for, but if what you want is to be able to upload files to a server through a web browser plus some database correspondance then I strongly suggest you go to pear.php.net and pick up a package for the uploading process. That will save you the headache of getting a potentially difficult and also security laden script written and let you concentrate on how you want the database to interact in the process. Someone above me suggested you created a table where the site admin flags files or something, that sounds like a good idea and could be achieved by creating a script that queried the table and printed out the information, with any formatting, onto the screen and then an update query that changed the status of files or removed them or something.

I have used this package in the past and it works well, I only have limited experience with it though.
[a href=\"http://pear.php.net/package/HTTP_Upload\" target=\"_blank\"]http://pear.php.net/package/HTTP_Upload[/a]
Anyway to conclude I suggest a process like this:
1. display form
2. gather form data and clean/check it
3. use the package to upload the file
4. upon success submit gathered data to database
5. admin logs in and sees file info
6. admin clears files to go live or something through a form
8. that form data is collected
9. database is updated and/or file is removed/moved
Looking for some easy-to-use tools?  Try these, https://sourceforge....jects/utils-php -- I made them myself.  They're distinct tools which are easy to understand and use.  See some examples uses at http://www.anotherearlymorning.com

#9 Kris

Kris
  • Staff Alumni
  • Advanced Member
  • 2,755 posts
  • LocationThe Internet

Posted 14 June 2006 - 04:06 PM

[a href=\"http://uk.php.net/manual/en/features.file-upload.php\" target=\"_blank\"]PHP Manual: Chapter 38. Handling file uploads[/a]. That is definitly worth the read. You can do basic error checking with the data provided by the $_FILES array, its worthwhile playing with the contents of $_FILES['userfile']['error'] too.

#10 Ninjakreborn

Ninjakreborn
  • Members
  • PipPipPip
  • Information Technology Specialist
  • 3,922 posts
  • Age:33

Posted 14 June 2006 - 04:13 PM

Ah some ideas, I will entertain both of these and see what I can come up with, after I get the form created more, and start some of the script, if I run into any difficulties, or want to ask any questions I think I will put them here instead of wasting room on another post, thanks for all the advice I greatly appreciate it.

Also any more ideas/theories/direction in the meantime would be nice to.

------

Business Website: http://www.infotechnologist.biz

Personal Website: http://www.joyelpuryear.com

Blog Site: http://www.realmofwriting.com
Services: Web development, application development, mobile development, and custom development. All services listed on my website.





0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users