473,387 Members | 1,481 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Redirection

I'm trying to use redirection to secure certain pages on my site. The
theory is to check to see if a user is "logged in" at the top of a
page, and if not, redirect them to a login page.

A typical web page will look like this:

<!--#include virtual="secure.php"-->
<html>
<body>
<p>Secure Content Here</p>
</body>
</html>

The secure.php file looks like this:

<?
session_start();

$schema = $_SERVER['SERVER_PORT'] == '443' ? 'https' : 'http';

// Check to see if the user is logged in.
if (! isset($_SESSION["userid"]))
{
header("Location: " . $schema .
exit();
}

?>

This all works fine in ASP. In PHP, however, I can't seem to get the
redirect to work. If I just type the secure.php URL directly into the
browser's address bar, it will redirect properly. If I call the page
I want to secure (either with a .html or a .php extension), it just
seems to ignore the redirect.

Any idea why?
Jul 17 '05 #1
2 1445
On 19 Jul 2004 09:09:44 -0700, br***@chameleon-systems.com (Bryan)
wrote:
I'm trying to use redirection to secure certain pages on my site. The
theory is to check to see if a user is "logged in" at the top of a
page, and if not, redirect them to a login page.

A typical web page will look like this:

<!--#include virtual="secure.php"-->
<html>
<body>
<p>Secure Content Here</p>
</body>
</html> This all works fine in ASP. In PHP, however, I can't seem to get the
redirect to work. If I just type the secure.php URL directly into the
browser's address bar, it will redirect properly. If I call the page
I want to secure (either with a .html or a .php extension), it just
seems to ignore the redirect.


If the page you want to secure is a .php, you need only use:

include("secure.php");

HTH,

--
David ( @priz.co.uk )

Jul 17 '05 #2
David Mackenzie <me@privacy.net> wrote...

If the page you want to secure is a .php, you need only use:

include("secure.php");


That was the issue. It was a .html page, not a .php page. ASP (or
more accurately, IIS) will allow you to do this, but apparently PHP
and/or Apache won't.

I ended up figuring out exactly what you suggested, and it worked.

Thanks for the response.

Bryan
Jul 17 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Albert Ahtenberg | last post by:
Hello, I don't know if it is only me but I was sure that header("Location:url") redirects the browser instantly to URL, or at least stops the execution of the code. But appearantely it continues...
52
by: Gerard M Foley | last post by:
Can one write a webpage which is not displayed but which simply redirects the user to another page without any action by the user? Sorry if this is simple, but I am sometimes simple myself. ...
15
by: Taki Jeden | last post by:
Hello everybody Does anybody know why w3c validator can not get pages that use 404 htaccess redirection? I set up two web sites so that clients request non-existent urls, but htaccess redirects...
2
by: Nadav | last post by:
Hi, Introduction: *************** I am trying to redirect stdout to a RichEdit control, this is done by initiating a StringWriter, associated it with a StringBuilder and setting the...
0
by: Dimitrios Mpougas | last post by:
Hello, I have two asp.net pages. The first is a page (main.aspx) wich has four links on it. The href value of each link is: href="view.aspx?id=1" traget="_blank" href="view.aspx?id=2"...
8
by: Luciano A. Ferrer | last post by:
Hi! I was following the http://www.seomoz.org/articles/301-redirects.php article, trying to do that with one of my test sites I added this to the .htaccess file: RewriteEngine On RewriteCond...
13
by: souissipro | last post by:
Hi, I have written a C program that does some of the functionalities mentionned in my previous topic posted some days ago. This shell should: 1- execute input commands from standard input,...
1
by: comp.lang.php | last post by:
require_once("/users/ppowell/web/php_global_vars.php"); if ($_GET) { // INITIALIZE VARS $fileID = @fopen("$userPath/xml/redirect.xml", 'r'); $stuff = @fread($fileID,...
4
by: psual | last post by:
hi newbie in web design I got some issue concerning a secure redirection between 2 pages let say I have a page with a grid (the 'master' page) in this grid I can select a record, get its pk...
13
by: Massimo Fabbri | last post by:
Maybe it's a little OT, but I'll give it try anyway.... I was asked to maintain and further develop an already existing small company's web site. I know the golden rule of "eternal" URIs, but...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.