Page 1 of 1

Form with multiple actions.

Posted: Mon Dec 21, 2009 11:05 pm
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!

Re: Form with multiple actions.

Posted: Tue Dec 22, 2009 1:01 am
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.

Re: Form with multiple actions.

Posted: Tue Dec 22, 2009 7:05 am
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...