Moorcam Posted July 14, 2017 Share Posted July 14, 2017 Howdy all. Not a bad evening here in VIC Anyways, I want to keep an ID in my URL after submitting a form. However, as we know, once you submit a form the page refreshes or redirects and I lose the elements from the URL as shown below: URL before submission: example.com/index.php?page_id=5 URL after submission: example.com/index.php Is it at all possible to keep the index.php?id=5 in the URL after submission? Thanks in advance. Quote Link to comment https://forums.phpfreaks.com/topic/304327-keeping-url-elements-after-form-submission/ Share on other sites More sharing options...
Solution requinix Posted July 14, 2017 Solution Share Posted July 14, 2017 Make the form submit to the URL you want, and/or make the code redirect to the URL you want. Really that simple. Quote Link to comment https://forums.phpfreaks.com/topic/304327-keeping-url-elements-after-form-submission/#findComment-1548328 Share on other sites More sharing options...
Moorcam Posted July 14, 2017 Author Share Posted July 14, 2017 Make the form submit to the URL you want, and/or make the code redirect to the URL you want. Really that simple. Yeah tried header Location but it still loses the elements for some reason. I already have the form submitting to itself, which is what I want it to do but it just loses the ?page_id=5 part and therefore shows a blank page because the data sent to the page from page_id is gone. Quote Link to comment https://forums.phpfreaks.com/topic/304327-keeping-url-elements-after-form-submission/#findComment-1548330 Share on other sites More sharing options...
Moorcam Posted July 14, 2017 Author Share Posted July 14, 2017 PMSL I am so tired. Got it. As simple as you said. action="edit-page.php?page_id=<?php echo $row['page_id']; ?>"> Thank you and apologies for being an ass Quote Link to comment https://forums.phpfreaks.com/topic/304327-keeping-url-elements-after-form-submission/#findComment-1548331 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.