stwong
-
Posts
3 -
Joined
-
Last visited
Never
Posts posted by stwong
-
-
Thanks to you all.
The apache running on my server supports both http and https. The cases where https is required are when user clicks the login button or some functions that require authentication. The action follows:
http://myserver/user.php?action=login
Then I add lines to beginning of user.php:
$url = $_SERVER['SERVER_NAME'];
$query = $_SERVER['QUERY_STRING'];
$path = $_SERVER['PHP_SELF'];
header("Location: https://$url$path?$query");
This redirects my browser to use https as expected. However, after successful user authentication, I don't know how to "switch back" to http since I've no idea about which URL that "calls" user.php.
I've to add header("Location: http://....") to every PHP script that will be invoked after authentication. I'm afraid this is not the right way to do that. Would anyone pls help?
Thank you ver much. -
Hi, all,
I'm newbie to PHP. I'm trying to modify a program so that all page except login are http. I try the header function as following:
--------------- cut here -------------
if (isset($_SERVER['HTTPS']) && ($_SERVER['HTTPS'] == "on")) {
$url = $_SERVER['SERVER_NAME'];
$query = $_SERVER['QUERY_STRING'];
$path = $_SERVER['PHP_SELF'];
header("Location: http://$url$path?$query");
}
--------------- cut here -------------
However, this always reload the "current" login page which is called from some other pages (html or PHP), e.g.
<a href="authenticate.php?action=login">
Would anyone please help? Sorry for the newbie question and poor English.
Thanks a lot.
Pls help: switching between http/https
in PHP Coding Help
Posted
Back from work.
if(stristr($_SERVER["SERVER_PROTOCOL"],'HTTPS'))
to determin if you're on the regular of secure server.
[/quote]
Then switch back to HTTP if procotol is HTTPS ? Thanks a lot.