Forum Moderators: coopster

Message Too Old, No Replies

PHP login redirect

hide dialog box and add IE support

         

WhosAWhata

3:31 am on Apr 25, 2005 (gmt 0)

10+ Year Member



i use a script to add multiple logins to a control panel. by giving everyone their own login, nobody can change the administrative password, but still has every other ability.

i use a script like this

<?
#gather login information
$string = "\n".$user.":".md5($pass)."\n";
if(eregi($string,$logins)){
header("Location:http://username:password@www.example.com/");
} else {
$error = "invalid login";
}
#yada yada yada
?>

this works for firefox, but not for IE
in firefox, it also displays a box saying "you are about to login in to 'example.com' under the name 'username'" or something to that effect and asks if they would like to proceed.

i don't want them knowing the username, so this is a downside

is there a way to login to a website for a user without them seeing the login information and that will work in all major browsers?

mcibor

9:53 pm on Apr 25, 2005 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member



you can use session to store the info:

session_start()

if(!isset($_SESSION["user"]))
{
//gather login info
//authenticate (I would use sql to store the user and md5, not file)
if($authentic) $_SESSION["user"] = $user;
else {}//do the login again
}

if($user = $_SESSION["user"])
{
//your code
}

you need to have session_start() at the beginning of a page. If the will be some page without it, the session will disappear.
best regards
Michal Cibor

WhosAWhata

12:58 am on Apr 26, 2005 (gmt 0)

10+ Year Member



forst of all i do plan on switching to mySQL, i just wanted to whip up a test login first, but thanks.

i know about sessions, but sessions only log you into your own site.

i need to have a login to a remote site.
firefox supports doing this as so
[USERNAME:PASSWORD@website.com...]

i need another way to login to an external page as this doesn't work in IE and also i don't want it to display a dialog box.

i guess i wasn't clear enough, but thanks for trying though

jatar_k

1:00 am on Apr 26, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



what about using curl [php.net] to do it? Not sure but it should work

WhosAWhata

1:24 am on Apr 26, 2005 (gmt 0)

10+ Year Member



i tried this

<?php
$ch = curl_init();
curl_setopt($ch, CURLOPT_USERPWD, "[USERNAME]:[PASSWORD]");
curl_setopt($ch, CURLOPT_URL, "http://www.example.com");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_exec($ch);
curl_close($ch);
?>

but it didn't work, instead it echoed the 404 page of example.com.

any ideas?

WhosAWhata

1:54 am on Apr 26, 2005 (gmt 0)

10+ Year Member



are there more options i need to set, or did i have the wrong syntax? i don't know that much about cURL. I just edited some sample code off of the PHP.net example code.

jatar_k

4:15 pm on Apr 26, 2005 (gmt 0)

WebmasterWorld Administrator 10+ Year Member



try looking through this, search for passwords

[curl.haxx.se...]