[PHP-DB] log in script // php-auth_user php_auth-pw

2001-03-14 Thread Marc Bragg

Hi

Does anyone have a simple php script for requiring entry of an email and
password (settable by user) for access, that is logged in mysql for
checking proper combination, and if new, creates new entry? I have a
script that adds the info to database, but what I need to do:

1. is if the info is already in the database, then it logs user to
specfic page, and

2. if not in database, then adds to db and then logs in to specific
page, and

3. if wrong combo, then does not log in.

can php_ auth_user  and php_auth_pw help?

Any help appreciated.


-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]




Re: [PHP-DB] log in script // php-auth_user php_auth-pw

2001-03-14 Thread Martin Edelius

Well a rather simple solution is:

$R_Check=mysql_query("select email from table where email='$email' and
password='$password'");
if(mysql_num_rows($R_Check)) { header("Location: log_in.php"); }
else
{
$Error="";

$R_Check=mysql_query("select email from table where email='$email'");
if(mysql_num_rows($R_Check)) { $Error="Email exists!\n"; }

$R_Check=mysql_query("select password from table where
password='$password");
if(mysql_num_rows($R_Check)) { $Error.="Password exists!\n"; }

if($Error) { header("Location: not_logged_in.php?error=$Error"); }
else
{
// Add info to DB here
// redirect with header() to proper page
}
}

I wrote this from the top of my head so it might not be the best solution,
or free from bugs for that matter 8), but it should give you a few pointers.
You can turn this into a function to make it easier to maintain and use in
multiple pages.

Hope it helps.


Best regards,
Martin Edelius

Spirex Digital Design

WWW: http://www.spirex.se  ||  MAIL: [EMAIL PROTECTED]
PHONE: +46-31-514651, 0708-113711  ||  FAX: +46-31-514331
Ards Industrivg 3, S-422 43 Hisings Backa

If I haven't got back to you or done what I'm supposed to, let me know again
as I have too much to do for my own good...

Got PHP4? http://www.php.net || http://www.zend.com


- Original Message -
From: "Marc Bragg" [EMAIL PROTECTED]
To: [EMAIL PROTECTED]
Sent: Wednesday, March 14, 2001 1:22 PM
Subject: [PHP-DB] log in script // php-auth_user php_auth-pw


 Hi

 Does anyone have a simple php script for requiring entry of an email and
 password (settable by user) for access, that is logged in mysql for
 checking proper combination, and if new, creates new entry? I have a
 script that adds the info to database, but what I need to do:

 1. is if the info is already in the database, then it logs user to
 specfic page, and

 2. if not in database, then adds to db and then logs in to specific
 page, and

 3. if wrong combo, then does not log in.

 can php_ auth_user  and php_auth_pw help?

 Any help appreciated.


 --
 PHP Database Mailing List (http://www.php.net/)
 To unsubscribe, e-mail: [EMAIL PROTECTED]
 For additional commands, e-mail: [EMAIL PROTECTED]
 To contact the list administrators, e-mail: [EMAIL PROTECTED]



-- 
PHP Database Mailing List (http://www.php.net/)
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
To contact the list administrators, e-mail: [EMAIL PROTECTED]