Solved

redirect to another page

Posted on 2006-11-28
6
275 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
ID: 18026537
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
ID: 18026617
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
ID: 18026645
Well as i read better in your case the first comment will do the job.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 4

Assisted Solution

by:jeffkee1985
jeffkee1985 earned 80 total points
ID: 18033180
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
ID: 18034067
<< 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
ID: 18035311
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

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
Build an array called $myWeek which will hold the array elements Today, Yesterday and then builds up the rest of the week by the name of the day going back 1 week.   (CODE) (CODE) Then you just need to pass your date to the function. If i…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

896 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

11 Experts available now in Live!

Get 1:1 Help Now