Form with multiple actions.

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
citrustech
Forum Newbie
Posts: 4
Joined: Sun Nov 22, 2009 6:14 pm

Form with multiple actions.

Post by citrustech »

Hello everyone,
I have a form right now with two fields - 1 being a text area, and - 2 being a file upload box. I want one submit button, and when pressed it should send the comments to the database and the uploaded file to a folder called uploads.
So really, my question is: How would i go about making a form with multiple 2 actions. Would i have to make the "form action" link to another php file, and within that php file have a IF statement that says: "If its coming from the textarea, do this. And if it's else, do this. If so, how would i go about doing that. (im not very good at php yet).
Thanks a lot you guys!
Griven
Forum Contributor
Posts: 165
Joined: Sat May 09, 2009 8:23 pm

Re: Form with multiple actions.

Post by Griven »

One form, one action.

What you want to do is this:

On your target PHP page (the one you specify in the action="" attribute of the form), prior to putting the comment in the database, you'll want an IF statement that checks to see if the $_FILE array is empty. If it is not (meaning a file was uploaded), you'll want to check to see if it is actually a picture and not some funky malware. If it passes that check (google "PHP file validation"), then you can move the file to the desired location and put the comment in the database.
indian98476
Forum Commoner
Posts: 78
Joined: Tue Dec 15, 2009 3:24 am

Re: Form with multiple actions.

Post by indian98476 »

http://www.w3schools.com/PHP/php_file_upload.asp


check out this link..u can add to this code for the required result...
Post Reply