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!
Form with multiple actions.
Moderator: General Moderators
Re: Form with multiple actions.
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.
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.
http://www.w3schools.com/PHP/php_file_upload.asp
check out this link..u can add to this code for the required result...
check out this link..u can add to this code for the required result...