0

I want to redirect the user to another page when they fill out my login form. I have an index.php and login.php for action file. How can I redirect using php?

sao
  • 1,835
  • 6
  • 21
  • 40
  • 2
    A tonne of people are going to answer "use header" very soon. Please remember that after using the header, everything following that line of code is still executed. So if you don't want that, do use ``exit`` immediately after sending the header. – Joel Hinz Oct 11 '13 at 18:07

4 Answers4

0

use this

header( 'Location: http://www.yoursite.com/new_page.html' ) ;

or

header( 'Location: /somepage.php' ) ;

for a local page.

gh123man
  • 1,372
  • 1
  • 14
  • 24
0

Before printing any HTML on the page, use the header function to tell the location for the request made by the user it's somewhere else, causing a redirect to that page.

header('Location: login.php');
Andrés Torres
  • 747
  • 5
  • 16
0

to redirect to another page use function header

vaibhavmande
  • 1,115
  • 9
  • 17
0

This will work if you haven't written anything on the page yet:

header( 'Location: http://www.yoursite.com/new_page.html' ) ;

If you have, you'll have to use javascript for redirection:

<script>window.location.href = "http://www.yoursite.com/new_page.html";</script>
zzxx53
  • 413
  • 3
  • 12