Firstly, don't write your code so that you actually move from one page (file) to another. Most of the websites I build have just one "page" although to the visitor, it looks like there are many pages. That one "page" contains a lot of conditionals to determine what the visitor will be presented with. It may take a while before you can refine your coding to the point of a single "page" but get your mind around the idea that what the visitors sees as a page, doesn't necessarily have to be a new file. So for instance, if you have presented the user with a list of records, and you want to give them the opportunity to delete records, you can go through the whole process in that same file. There are many ways to do this. The best way is to use AJAX, but it can also be done with just PHP. PHP cannot redirect from one script to another after anything has been sent to the browser. You can have many lines of computer code before the the redirect, but once anything, even just a <html> tag has been sent, you can't redirect using PHP. That being said, the method of redirecting using PHP is like this: header('Location:../index.php'); die(); With Javascript, you can redirect at any point. the code is similar but I'm not going to show it here. So using PHP, what you would do is put code like this at the very top of the script: if (is_numeric ($_GET['confirmed'])){ //check if the GET variable confirmed has been populated (because someone clicked a "confirm delete" link $id=$_GET['confirmed']; //just to convert the GET variable to a local variable if ($dbh->exec("DELETE FROM mytable WHERE id='$id'")){ //this code performs the delete, and also, if the delete was successful, redirects to the index.php page. header('Location:../index.php'); die(); //this makes sure the current script stops running. } else { $message = "woops! Didn't work."; //if the delete didn't work, the variable message is loaded; }} Since you have not studied PHP yet, there is a lot in this example that you won't understand, though I provided comments to explain the logic Anyway, I would not redirect to a different page, as the example does, but would simply refresh the existng script. The whole record list, delete, confirm, and return process would be done in the same script.
... View more