Jump to content

getting a form post to change a get value


Rhysickle

Recommended Posts

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

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.