yandoo Posted January 24, 2008 Share Posted January 24, 2008 Hi there, Is is possible to get a submit button to not only submit (insert) record but to then parse the record ID (of the record it has just inserted) to another page....so the details of the record (that was submitted) can be seen????? I can do it with a hyperlink but how with a submit button??????? Thank you Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/ Share on other sites More sharing options...
kts Posted January 24, 2008 Share Posted January 24, 2008 is there a form? if so put the value for of the variable in a <input type="hidden" name="varname" value="<?php echo $variable; ?>"> make sure the form is to method="post" and then on the page it goes to do $_POST['varname'] Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448202 Share on other sites More sharing options...
PHP Monkeh Posted January 24, 2008 Share Posted January 24, 2008 After you've submitted the data on the page, just run another query which will order by ID descending, and limit it to 1 result, like this: <?php $query = "SELECT * FROM myTable ORDER BY id DESC LIMIT 1"; $result = mysql_query($query) or die(mysql_error()); $newEntry = mysql_fetch_object($result); ?> That will return last entry to your table, make sure you put this after the insert though or you'll get the info of the one before the last entry! Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448207 Share on other sites More sharing options...
yandoo Posted January 24, 2008 Author Share Posted January 24, 2008 Thanks for the reply thats gr8! I know what you your saying with code u sugested it im making a form that is completed over 2 different pages. I hoped it was possible that when submitting the record on the 1st page...it would then take you to the 2nd page (which it does) but then dynamically display the same record results just submitted. Is it possible to parse the record ID from page to page with a submit button?? thank you Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448252 Share on other sites More sharing options...
PHP Monkeh Posted January 24, 2008 Share Posted January 24, 2008 On the second page, you could just echo out the information that was submitted from the previous form? And then if you're wanting to then submit those details in addition to the ones completed in the second page of the form, do what kts said and store their values in hidden fields. Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448263 Share on other sites More sharing options...
yandoo Posted January 24, 2008 Author Share Posted January 24, 2008 Hey thats brill, i know what you mean, i think ill do it this way. I just had it stuck in my head in terms of parsing a record ID in a hyperlink to another page (as well as insert record) thanks Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448275 Share on other sites More sharing options...
PHP Monkeh Posted January 24, 2008 Share Posted January 24, 2008 Yeah don't insert the record till they've completed the second part of the form, and just insert all the results at once when they've submitted the second bit (as you've included all the first parts values in hidden fields!). Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448284 Share on other sites More sharing options...
yandoo Posted January 24, 2008 Author Share Posted January 24, 2008 But then using the form how do i post all of the details the user has inputed in the fields to the next page and form (to be updated)...??? Sorry im bit of newbiew at this. Thanks Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448292 Share on other sites More sharing options...
PHP Monkeh Posted January 24, 2008 Share Posted January 24, 2008 You have x amount of fields on page1.php that the user fills out right? Lets say, First Name + Surname. Then they submit those (but not insert to the database) and go to page2.php, where there's some more fields for them to fill out (lets say Birthdate and Postcode). You don't want to get them to input first name + surname again, nor do they need to be able to edit them. So you store them in hidden fields, so that when they submit page2.php, you can access first name + surname as $_POST variables. You could also echo out the first name + surname on page2.php if you wanted, just so they can see what they entered. Once page2.php is submit, you insert all the fields to your table Unless I've totally misunderstood your original question of course Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448301 Share on other sites More sharing options...
yandoo Posted January 24, 2008 Author Share Posted January 24, 2008 Hey thats brill! I managed to work around this with all your help! thanks again Quote Link to comment https://forums.phpfreaks.com/topic/87629-solved-submit-button-submit-record-parse-recordid-to-next-page/#findComment-448345 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.