Re: Member authentication with PHP and MySQL

From: Date: Mon, 13 Aug 2001 15:45:56 +0000
Subject: Re: Member authentication with PHP and MySQL
References: 1 2 3  Groups: php.db 
Request: Send a blank email to php-db+get-11298@lists.php.net to get a copy of this message
My Script uses a Session ID Variable when verifying the user You don't have a field setup for this. So either change the code in this section $timer = md5(time()); $sid = $email . "+" . $timer; SetCookie("ElectrocutedClanRemains",$sid,time()+2592000); $query = "update members set sid=\"$timer\" where email=\"$email\""; or Add to your DB sid char(32) (md5 always returns a 32 character long string) Sheridan Saint-Michel Website Administrator FoxJet, an ITW Company www.foxjet.com ----- Original Message ----- From: Cato Larsen <ravenno1@world-online.no> To: <php-db@lists.php.net> Sent: Monday, August 13, 2001 10:10 AM Subject: Re: [PHP-DB] Member authentication with PHP and MySQL > Arg... > > I get this error: > > > Unable to update database. Please contact ravenno1@world-online.no. > > > > Am I missing something in my DB? > > Fields in DB: > > id, email, password, name, loc, aim, icq, msn, yahoo, charname ,charsname, > charnick, tit, lvl, picurl, born, appearance, charac, streng, bio, breed, > prof, posn. > > > > This is the current source: > > > > <?php > > file://Put in your own info for username, password, DB, email@address, > Cookiename, > file://the name of this page (currently login.php) and the name of your subscribe > file://or new user page (currently new.php). I went ahead and included all the > HTML > file://so this page should work as is, with only the changes described above > needed > // - Lysander (Lysander@onlychildclub.com) > > $dblink = > mysql_pconnect("localhost","Xephiroth","lordoftherings"); > mysql_select_db("members"); > > $headers=0; file://Make Sure HTML Headers are in place before the form > > > file://after Authenticating the script automatically sends the browser to > file://the webpage of your choice (note if your page calls this > file://script with ?redirect="foobar.php" it will automatically > file://redirect to foobar.php after authenticating. Set the default > file://redirect page here > > if ( !isset($redirect)) > { > $redirect = "default.php"; > } > > if (isset($email) && isset($password)) { > > $query = "select * from memberinfo where email = \"$email\" and password = > \"$password\""; > > if ( !($dbq = mysql_query($query, $dblink))) { > echo "Unable to query database. Please Contact <a > > href=\"mailto:ravenno1@world-online.no\">ravenno1@world-online.no</a>.\n"; > exit; > } > > $lim = mysql_num_rows( $dbq ); > > if ($lim != 1) { > > $headers=1; file://HTML headers in place > echo "<html>"; > echo "<head>"; > echo "<title>Member logon</title>"; > echo "<meta http-equiv=\"Content-Type\" content=\"text/html; > charset=iso-8859-1\">"; > echo "</head>"; > echo "<body bgcolor=\"#000000\" text=\"#FFFFFF\" > leftmargin=\"0\" > topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" > background=\"../images/back.gif\" bgproperties=\"fixed\" > link=\"#CCCCCC\" > vlink=\"#CCCCCC\" alink=\"#CCCCCC\">"; > echo "<B>Invalid E-Mail adress and/or Password. Please Try > again</B><BR>"; > > } > > if ($lim == 1) { > > file://make unique session id and store it in Database > $timer = md5(time()); > $sid = $email . "+" . $timer; > SetCookie("ElectrocutedClanRemains",$sid,time()+2592000); file://Set Cookie for > 30 days > $query = "update members set sid=\"$timer\" where > email=\"$email\""; > > if( !($dbq = mysql_query( $query, $dblink))) { > echo "Unable to update database. Please contact <a > href=\"ravenno1@world-online.no\">ravenno1@world-online.no</a>.\n"; > exit; > } > > $headers=1; > header("Location: $redirect"); > exit; > } > > } > > if (isset($ElectrocutedClanRemains)) { > $headers=1; file://make sure HTML headers are in place before the form > $sidarray = explode("+", "$ElectrocutedClanRemains"); > $query = "select * from memberinfo where email = \"$sidarray[0]\" and sid > = \"$sidarray[1]\""; > > if ( !($dbq = mysql_query($query, $dblink))) { > echo "Unable to find database. Please Contact <a > > href=\"mailto:ravenno1@world-online.no\">ravenno1@world-online.no</a>.\n"; > exit; > } > > if (mysql_num_rows( $dbq ) == 1) { > echo "<html>"; > echo "<head>"; > echo "<title>Member logon</title>"; > echo "<meta http-equiv=\"Content-Type\" content=\"text/html; > charset=iso-8859-1\">"; > echo "</head>"; > echo "<body bgcolor=\"#000000\" text=\"#FFFFFF\" > leftmargin=\"0\" > topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" > background=\"../images/back.gif\" bgproperties=\"fixed\" > link=\"#CCCCCC\" > vlink=\"#CCCCCC\" alink=\"#CCCCCC\">"; > echo "You are already logged in as $sidarray[0].<BR>"; > echo "You may logon as another user or simply begin using our services with > your current session.<BR>"; > } > } > > if ($headers == 0) { > echo "<html>"; > echo "<head>"; > echo "<title>Member logon</title>"; > echo "<meta http-equiv=\"Content-Type\" content=\"text/html; > charset=iso-8859-1\">"; > echo "</head>"; > echo "<body bgcolor=\"#000000\" text=\"#FFFFFF\" > leftmargin=\"0\" > topmargin=\"0\" marginwidth=\"0\" marginheight=\"0\" > background=\"../images/back.gif\" bgproperties=\"fixed\" > link=\"#CCCCCC\" > vlink=\"#CCCCCC\" alink=\"#CCCCCC\">"; > } > > echo "<table width=\"846\" border=\"0\" cellspacing=\"0\" > cellpadding=\"0\">"; > echo "<tr>"; > echo "<td width=\"80\" > height=\"30\">&nbsp;</td>"; > echo "<td height=\"30\">&nbsp;</td>"; > echo "</tr>"; > echo "<tr>"; > echo "<td width=\"80\">&nbsp;</td>"; > echo "<td>"; > echo "<table width=\"766\" border=\"0\" cellpadding=\"0\" > cellspacing=\"0\">"; > echo "<tr>"; > echo "<td colspan=\"3\">"; > echo "<div align=\"center\">"; > echo "<table width=\"766\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\" > background=\"../images/middletop.gif\">"; > echo "<tr>" ; > echo "<td width=\"8\"><img src=\"../images/left.gif\" > width=\"8\" > height=\"29\"></td>"; > echo "<td background=\"../images/middletop.gif\" align=\"left\" > valign=\"middle\"><font color=\"#333333\"><b><font > size=\"4\">Member Logon > </font></b></font><font size=\"4\" face=\"Times New Roman, > Times, serif\" > color=\"#333333\">"; > echo "<b> </b></font></td>"; > echo "<td width=\"9\">"; > echo "<div align=\"right\"><img src=\"../images/right.gif\" > width=\"8\" > height=\"29\"></div>"; > echo "</td>"; > echo "</tr>"; > echo "</table>"; > echo "</div>"; > echo "</td>"; > echo "</tr>"; > echo "<tr>"; > echo "<td width=\"3\" > background=\"../images/framev.gif\"><img > src=\"../images/framev.gif\" width=\"3\" > height=\"100%\"></td>"; > echo "<td bgcolor=\"#333333\" width=\"760\" > align=\"center\" > valign=\"middle\">"; > echo "<form name=\"auth\" method=\"post\" > action=\"vault.php\">"; > echo "<table width=\"100%\" border=\"0\" > cellspacing=\"0\" > cellpadding=\"0\">"; > echo "<tr>"; > echo "<td colspan=\"2\">Please enter your e-mail adress and password to > access the supersecretandultracool members section:</td>"; > echo "</tr>"; > echo "<tr>"; > echo "<td width=\"50%\" align=\"right\" > valign=\"middle\">E-Mail: </td>"; > echo "<td width=\"50%\" valign=\"middle\">"; > echo "<input type=\"text\" name=\"email\" > size=\"45\">"; > echo "</td>"; > echo "</tr>"; > echo "<tr>"; > echo "<td align=\"right\" valign=\"middle\">Password: > </td>"; > echo "<td valign=\"middle\">"; > echo "<input type=\"password\" name=\"password\" > size=\"45\">"; > echo "</td>"; > echo "</tr>"; > echo "</table>"; > echo "<input type=\"submit\" name=\"Submit\" > value=\"Login\">"; > echo "<Input Type=\"hidden\" Name=\"redirect\" > Value=\"$redirect\">"; > echo "</form>"; > echo "</td>"; > echo "<td width=\"3\" > background=\"../images/framev.gif\"><img > src=\"../images/framev.gif\" width=\"3\" > height=\"100%\"></td>"; > echo "</tr>"; > echo "<tr>"; > echo "<td height=\"3\"><img src=\"../images/blcorner.gif\" > width=\"3\" > height=\"3\"></td>"; > echo "<td height=\"3\" > background=\"../images/frameh.gif\"><img > src=\"../images/frameh.gif\" width=\"100%\" > height=\"3\"></td>"; > echo "<td height=\"3\"><img src=\"../images/brcorner.gif\" > width=\"3\" > height=\"3\"></td>"; > echo "</tr>"; > echo "</table>"; > echo "</td>"; > echo "</tr>"; > echo "</table>"; > echo "</body>"; > echo "</html>"; > ?> > > > > > > Thanks for your support! > > > > Best Regards Cato > > > > > -- > 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 (#11298) next »