Re: Member authentication with PHP and MySQL

From: Date: Mon, 13 Aug 2001 15:10:15 +0000
Subject: Re: Member authentication with PHP and MySQL
References: 1 2  Groups: php.db 
Request: Send a blank email to php-db+get-11295@lists.php.net to get a copy of this message
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 //Put in your own info for username, password, DB, email@address, Cookiename, //the name of this page (currently login.php) and the name of your subscribe //or new user page (currently new.php). I went ahead and included all the HTML //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; //Make Sure HTML Headers are in place before the form //after Authenticating the script automatically sends the browser to //the webpage of your choice (note if your page calls this //script with ?redirect="foobar.php" it will automatically //redirect to foobar.php after authenticating. Set the default //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; //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) { //make unique session id and store it in Database $timer = md5(time()); $sid = $email . "+" . $timer; SetCookie("ElectrocutedClanRemains",$sid,time()+2592000); //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; //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

« previous php.db (#11295) next »