Re: log in script // php-auth_user php_auth-pw

From: Date: Wed, 14 Mar 2001 12:27:29 +0000
Subject: Re: log in script // php-auth_user php_auth-pw
References: 1  Groups: php.db 
Request: Send a blank email to php-db+get-7443@lists.php.net to get a copy of this message
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: martin.edelius@spirex.se PHONE: +46-31-514651, 0708-113711 || FAX: +46-31-514331 Aröds Industriväg 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" <msbjustice@mindspring.com> To: <php-db@lists.php.net> 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: php-db-unsubscribe@lists.php.net > For additional commands, e-mail: php-db-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net >

« previous php.db (#7443) next »