Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

In a loop.

Status
Not open for further replies.

tijerina

Vendor
Mar 4, 2003
132
US
I am using the "header" method (per some awesome feedback from this forum) to redirect from http to https. I added the "header" method to the top of my index.php file.

----start of snip-------------------

<?php
header("Location:
$user_login = "";
if(isset($_REQUEST['user_login'])){
$user_login = $_REQUEST['user_login'];
if (isset($_REQUEST['username'])){
session_start();
$HTTP_SESSION_VARS['valid_user'] = $_REQUEST['username'];
$username = $HTTP_SESSION_VARS['valid_user'];
}
}

--------end of snip----------------

But, when I go to the site, it is as if the site is in a loop. I can see the bottom of my ie browser and it is flashing with a "redirecting" and a "connecting" non stop.

Anybody have any ideas?

I have posted this question on another thread and do apologize for multi-threading, but wanted to start fresh to avoid the clouds in my head. Again, I do apologize.

Thanks.
 
Is the location you are redirecting to the same page? If it is, then this would cause what you are experiencing. As soon as the server parses the script to the point of header call it redirects the page and does not execute the code after that call.

You could either redirect to another page, which doesn't redirect any further or enclose the header call in an if clause which would cause redirect only when certain criteria is met.
 
Thanks for the reply..

I do see your point, silly of me.. I am not sure where to put the header call.

Thanks for your time.

 
You need to check if https is the current protocol.
Print out the server environment variables and see which one to test for. Print it out a) using http then b) https and you'll see which var indicates the use of SSL.
Then, make an if statement that checks for SSL. If no SSL, then use the header directive. Otherwise the statement will be skipped, no looping will occur.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top