• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 319
  • Last Modified:

redirect to another page

hi

Please assist how can we redirect to another page when the user has successfully login?

      $result = mysql_query($myQuery);
      $row = mysql_fetch_array($result);
      $myID=$row["AccessID"];
      mysql_close();
      //test
      if ($myID==12345)
      {
            session_start();
            $_SESSION['AccessID']=$myID;
                                <-------------------------------------------------------------redirect to ../../main/index.php
                else { echo "Login failed."; }

Thanks.
0
FrankPorter
Asked:
FrankPorter
4 Solutions
 
Guy Hengel [angelIII / a3]Billing EngineerCommented:
header("Location: "../../main/index.php");

you have however to take care that there is NO output generated (print/echo/html) before the header function is run,.
0
 
ch2Commented:
If the file is moved permanently you can use like this.

<?php
header('HTTP/1.1 301 Moved Permanently');
header('Location: http://www.example.com/redirecto.html');
header('Connection: close');
exit;
?>
0
 
ch2Commented:
Well as i read better in your case the first comment will do the job.
0
Get your problem seen by more experts

Be seen. Boost your question’s priority for more expert views and faster solutions

 
jeffkee1985Commented:
I usually put in Meta tags - to put headers in it can get messy and complicated, and may interfere with other header things.

echo "<META HTTP-EQUIV=\"Refresh\" CONTENT=\"0; URL=index.php\">";
0
 
ch2Commented:
<< to put headers in it can get messy and complicated, and may interfere with other header things.

which are those headers thing? could you explain why get complicated? why messy?
0
 
ygouthamCommented:
setting up a meta tag might not pass on any variables between the pages. it is only a count and i have personally experienced difficulty in handling session cookies (irrespective of placing a meta tag after session_start(), placing values in cookies, etc) and have a meta tag with counter zero has no effect and sends the user back to the login page to relogin => creating a indeterminate loop.

0

Featured Post

[Webinar] Improve your customer journey

A positive customer journey is important in attracting and retaining business. To improve this experience, you can use Google Maps APIs to increase checkout conversions, boost user engagement, and optimize order fulfillment. Learn how in this webinar presented by Dito.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now