Jabop Posted March 15, 2008 Share Posted March 15, 2008 I have a small form that submits a form named 'article' into a database. There is a checkbox on the form that, if checked, will redirect to an upload page. I have a table in my database for the article, and a separate database for the uploaded images. Article Table: ID | Article Name | Article Body Image Table: ID | ArticleID | ImgName | ImgExt If the checkbox is selected, I redirect the user to the upload page. I thought this would be a good way to do it, because the method is different when uploading something. Once they submit the form, and the check box is NOT selected, it submits info to the Article table. If they have the form checked, I want to go to a new page, and upload the image, joining the record on its respective Article ID. However, I am lost as to how to match the last ID of the article (not sure how to get the ID for that when on the next page) to give the image that's being uploaded a record to join on the images ID. Any assistance is appreciated. Quote Link to comment Share on other sites More sharing options...
lordfrikk Posted March 15, 2008 Share Posted March 15, 2008 Is this what you need? http://us.php.net/mysql_insert_id Quote Link to comment Share on other sites More sharing options...
Jabop Posted March 15, 2008 Author Share Posted March 15, 2008 Is this what you need? http://us.php.net/mysql_insert_id Yes! That looks about what I need. Thank you! Another question: Would I have to set it in a Session var to get the ID on my next page? [pre] INSERT ("asdf"); $SubmissionID=mysql_insert_id(); /* or */ $_SESSION['logged']['upload']['SubmissionID']=mysql_insert_id(); [/pre] Quote Link to comment Share on other sites More sharing options...
lordfrikk Posted March 15, 2008 Share Posted March 15, 2008 Yes you would, or you could append it to the query (e.g. upload.php?sub_id=$SubmissionID), then you can get in via $_GET['SubmissionID']. But if you ask me - use sessions Quote Link to comment 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.