Rhysickle Posted August 3, 2008 Share Posted August 3, 2008 Hello, I have a dynamic php page which displays several different subpages. So for each subpage the url is sites.php?site=[subpage name]. Each of these subpages contains a post form, and one of the fields gives the user the option to change the subpage name that appears in the url. What I have at the moment is: if ($_POST) { //validate and submit the form to the database $_GET['site'] = $_POST['site']; } if($_GET['site']) { //draw the form, filling the fields with entries from the database or (if the form was submitted with errors) the $_POST values and error messages } else { //draw a list of links to the subpages i.e links to sites.php?site=[site name] } Now, the site field in the database is being updated to the new value, and after the post the field in the form reflects this. BUT the url doesn't change to reflect this - it still uses the old $_GET['site'] value. I have 2 questions: Why is anything being displayed at all when the old $_GET['site'] has been wiped from the database? Why, when I have $_GET['site'] = $_POST['site']; before the page redraw, does the page not use the new $_GET['site'] value in the url. Should I use some other method to get a post to change a get value? Thanks in advance for any help Rhys Link to comment https://forums.phpfreaks.com/topic/117972-getting-a-form-post-to-change-a-get-value/ Share on other sites More sharing options...
unkwntech Posted August 3, 2008 Share Posted August 3, 2008 You can't set GET in the URL by assigning the variable, you have to send the user to a page with the GET already set, i.e doamin.tld/file.ext?myVar=varValue Link to comment https://forums.phpfreaks.com/topic/117972-getting-a-form-post-to-change-a-get-value/#findComment-606909 Share on other sites More sharing options...
peranha Posted August 3, 2008 Share Posted August 3, 2008 Use the post to update the url with the new page. then use get to get that page on submit use sites.php?site="$_POST " Link to comment https://forums.phpfreaks.com/topic/117972-getting-a-form-post-to-change-a-get-value/#findComment-606911 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.