groston Posted November 18, 2021 Share Posted November 18, 2021 (edited) I have created a simple web site that is used to enter data into a database. Each page essentially has: <form role="form" method="post"> ... </form> The site works without issue. However, I want to add to the form the ability to upload an image file. I wrote a small test page that does this and it works without issue. However, the problem is this: The test page has the following: <form action="fileUploadScript.php" method="post" enctype="multipart/form-data"> The first <form> uses code on the page itself to do the database insertion, whereas the second <form> uses an external php file to upload the file. In terms of executing the code, I suspect that I could make this work with two mouse clicks: one to upload the file and the other to enter the data. Is there a way to achieve this with one mouse click? Note that there are a dozen fields or so, and identifying all of them to have the external php file handle them might be a pain... Thanks. Edited November 18, 2021 by groston removed blank line and unneeded quote Quote Link to comment https://forums.phpfreaks.com/topic/314249-combine-internal-and-external-post/ Share on other sites More sharing options...
Barand Posted November 19, 2021 Share Posted November 19, 2021 Then move all the processing to the same place - one or the other Quote Link to comment https://forums.phpfreaks.com/topic/314249-combine-internal-and-external-post/#findComment-1592239 Share on other sites More sharing options...
ginerjm Posted November 19, 2021 Share Posted November 19, 2021 Is there a reason you have defined 2 forms? Why not one to include all of your 'data' in one process/one click? Quote Link to comment https://forums.phpfreaks.com/topic/314249-combine-internal-and-external-post/#findComment-1592240 Share on other sites More sharing options...
groston Posted November 19, 2021 Author Share Posted November 19, 2021 Yeah, I figured this out. I simply put the upload code inside a if that checks to see if the button was pushed. Sorry to have wasted everyone's time - some more thinking and I figured it out. Thanks. Quote Link to comment https://forums.phpfreaks.com/topic/314249-combine-internal-and-external-post/#findComment-1592244 Share on other sites More sharing options...
ginerjm Posted November 19, 2021 Share Posted November 19, 2021 Good work! Although a lot of people here don't rely on 'checking' the button but I live by that and have never had an issue. Quote Link to comment https://forums.phpfreaks.com/topic/314249-combine-internal-and-external-post/#findComment-1592248 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.