943,582 Members | Top Members by Rank

Ad:
  • PHP Discussion Thread
  • Unsolved
  • Views: 4123
  • PHP RSS
Aug 9th, 2004
0

php help needed for login

Expand Post »
i cant get a login script to work so imma take the easy way out and ask if ne1 will give me one plzplzplzplzplz

:cry:
Similar Threads
Reputation Points: 10
Solved Threads: 0
Newbie Poster
browny87us is offline Offline
1 posts
since Aug 2004
Aug 9th, 2004
0

Re: php help needed for login

tell us what the problem is and post some code and we can probably help
Reputation Points: 10
Solved Threads: 0
Junior Poster in Training
Ragnarok is offline Offline
94 posts
since Mar 2004
Aug 12th, 2004
0

Re: php help needed for login

I highly recommend the free version of Cookie Password Protection. I use it on my site to protect certain database interfaces I don't want people getting into.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
pcarlow is offline Offline
22 posts
since Jun 2004
Aug 12th, 2004
0

Re: php help needed for login

hey, if u find someone that knows how to do login php script, email me. my friend is setting up an rpg. having a login screen would be kool where he would not have to put u in himself. when putting in the login name, i would like to go straight to my member stats kinda like yahoo for the mail accont.

ill post the site when i talk to him next.

if anyone else can help me and him out, email me and ill give him ur email address and he'll email u about his site.
Reputation Points: 10
Solved Threads: 0
Newbie Poster
dragonkingamn is offline Offline
3 posts
since Aug 2004
Aug 13th, 2004
0

Re: php help needed for login

How about using PHP sessions like this:
<?php

if (!isset($PHP_AUTH_USER) || !isset($PHP_AUTH_PW)) {
//If the PHP session variables aren't set, ask for name and password
header('WWW-Authenticate: Basic realm="Authorized Users Only"');
header('HTTP/1.0 401 Unauthorized');
exit;

} else if (isset($PHP_AUTH_USER) && isset($PHP_AUTH_PW)) {

//If the variables are set, check the username and password against a //database.

$conn = pg_Connect("host=localhost dbname=[dbname] port=[portnumber]");

$result = pg_Exec($conn,
"SELECT *
FROM [table]
WHERE username='$PHP_AUTH_USER' AND
password='$PHP_AUTH_PW';");

$num = pg_NumRows($result);
$i = 0;

//If the user is authenticated against the database, echo the html code for //the page you want them to see

if ($num != 0) {
echo "<HTML> ...... </HTML>"
}
}
?>

Use this configuration for any web page on your site that should have restricted access, then rename those files with a .php extension. In this example the connection is to a PostgreSQL database on my linux server, you may need a different connection string/method for your needs, but this works great otherwise. Once a user provides their login information they can immediately access any of the pages with the php code. Their login wont be lost until they close their browser, or you could give them a logout option that would reset the user and password variables. I found the original tutorial on this at this address: http://webmonkey.wired.com/webmonkey...tw=programming

Hope this helps!
Reputation Points: 10
Solved Threads: 0
Newbie Poster
AK47 is offline Offline
12 posts
since Aug 2004
Aug 15th, 2004
0

Re: php help needed for login

Quote originally posted by browny87us ...
i cant get a login script to work so imma take the easy way out and ask if ne1 will give me one plzplzplzplzplz

:cry:
For starters you need to give more information...do you have mysql databases, do you even have php?
Reputation Points: 13
Solved Threads: 2
Junior Poster
YoungCoder is offline Offline
193 posts
since Aug 2004

This thread is more than three months old

No one has posted to this discussion for at least three months. Please let old threads die and do not reply to them unless you feel you have something new and valuable to contribute that absolutely must be added to make the discussion complete. Otherwise, please start a new thread in this forum instead.
Message:
Previous Thread in PHP Forum Timeline: the form cant remember me ?????
Next Thread in PHP Forum Timeline: help for connection to mysql





About Us | Contact Us | Advertise | Acceptable Use Policy
Forum Index | Build Custom RSS Feed


Follow us on Twitter


© 2011 DaniWeb® LLC