Solved

redirect to another page

Posted on 2006-11-28
6
267 Views
Last Modified: 2008-03-06
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
Comment
Question by:FrankPorter
6 Comments
 
LVL 142

Accepted Solution

by:
Guy Hengel [angelIII / a3] earned 350 total points
Comment Utility
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
 
LVL 11

Assisted Solution

by:ch2
ch2 earned 20 total points
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
Well as i read better in your case the first comment will do the job.
0
What Security Threats Are You Missing?

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

 
LVL 4

Assisted Solution

by:jeffkee1985
jeffkee1985 earned 80 total points
Comment Utility
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
 
LVL 11

Expert Comment

by:ch2
Comment Utility
<< 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
 
LVL 14

Assisted Solution

by:ygoutham
ygoutham earned 50 total points
Comment Utility
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

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

Both Easy and Powerful How easy is PHP? http://lmgtfy.com?q=how+easy+is+php (http://lmgtfy.com?q=how+easy+is+php)  Very easy.  It has been described as "a programming language even my grandmother can use." How powerful is PHP?  http://en.wikiped…
Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
The viewer will learn how to count occurrences of each item in an array.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

13 Experts available now in Live!

Get 1:1 Help Now