You can do what you mention in the comments of javascript:history.back(-1)
, but that can present some problems:
-
If the user has JavaScript disabled, it will not work directly.
-
The user can see a blank window before redirecting to the previous page.
- JavaScript is an intermediary that is doing something you could do directly with PHP.
- Doing a
history.back(-1)
can dislocate the web application (although if this happens, you have more serious problems).
That's why I would recommend that you redirect it directly with PHP, using the function header
that you also mention in the question. For what you comment, all you need to do is pass the parameter with the ID. But that's simple if the URL is view_fases.php?iddrs=2
then your code would be something like this:
<?php
// lee el valor del parámetro iddrs
$iddrs = $_GET["iddrs"];
// haz las operaciones que tengas que hacer para la actualización
// ...
// redirecciona a la página anterior
header("Location:view_fases.php?iddrs=" . $iddrs);
An important fact to keep in mind: the redirection with header
will give an error if some content has been written before (with echo
, print
, var_dump
, etc.), because it can not be changed the header information once the data output has started.