Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

204
Vistas
Ho to go to the previous page refreshing and without saving actual in history

after some code has been executed, I want the user of my website to be redirected to the previous page of the provious page.

Ex.
Home Page -> LogIn Page (form) -> LogIn page (logging code) -> Home Page

At the moment I'm doing this with PHP and javascript as below:

echo "<script>history.go ( -2); Location.reload ()</script>";

This code is working as I want:
The user is visiting the website, then he want to login so it goes to the LogIn page, the form redirect to a service page and then I want to user to be redirected to the page he was reading (in the example the Home Page).

The problem is that in the browser hystory the user is able to see the service page, what can I do to solve the problem?
I need the user to be redirected, but also the page to be refreshed as in the menu the LogIn button need to be changed with the LogOut button.

Real:
Home Page -> LogIn Page (form) -> LogIn page (logging code) -> Home Page (reloaded)

In hystory:
Home Page -> LogIn Page (form) -> Home Page (reloaded)

about 4 years ago · Juan Pablo Isaza
1 Respuestas
Responde la pregunta

0

I would suggest that you use php redirects only, not javascript. Unless you’re using ajax, the responsibility lies with the server (and with ajax you wouldn’t be leaving the page anyway).

  1. Send current URI in GET request to login. (use the query string: <a href="/login.php?uri=<?= $_SERVER['PHP_SELF'] ?>">Log in</a>)
  2. Send URI along with other variables (user/pass) in login form submission (POST)
  3. Be sure to sanitize user input (URI)
  4. Process login info (including logging) and redirect to URI or redirect to a failure page (if desired)
about 4 years ago · Juan Pablo Isaza Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda