RE: [PHP-DB] MySQL (2 tables)

From: Date: Tue, 17 Oct 2000 20:27:40 +0000
Subject: RE: [PHP-DB] MySQL (2 tables)
Groups: php.db 
Request: Send a blank email to php-db+get-3697@lists.php.net to get a copy of this message
Why not (not actual code...just a quick brainstorm) SELECT * FROM auth If ((username == $username) && (password == $password)){ SELECT * FROM users display info } else { tell them they entered something wrong and are unauthorized } or if you wanted to do it in one SELECT SELECT users.*,auth.username,auth.password FROM users, auth John Guynn -----Original Message----- From: bryan [mailto:bryan@concept-factory.com] Sent: Tuesday, October 17, 2000 3:14 PM To: php-db@lists.php.net Subject: [PHP-DB] MySQL (2 tables) I have 2 tables in my database (users, and auth). My query is SELECT * FROM users; but I only want to show that query if the user is a member (from the auth table) I have a $PHP_SELF function in my form so when the user logs in, if it is valid, they are shown the data from the users table. Could someone tell me how to validate the username && password from the AUTH table and show the data from the USERS table.. Thanks... bryan eg. <?php If (($username == username) && ($password == password)) { print "<TABLE $table_params>"; print "<TR>"; if ((!$result) || ($numrows < 1)) { echo "<H1>ERROR - no rows returned</H1><P>" } print "</TR>"; while ($row = mysql_fetch_array ($result)) { print "<TR>"; echo "<TD><U><B>ID Number:</TD></U></B>". "<TD>".$row[0]."</TD>"; echo "<TD><U><B>Name:</U></B></TD> "."<TD>".$row[1]."&nbsp;".$row[2]."</TD>"; print "<TD><a href=\"mailto:" . $row[3] . "\">". "E-mail me</a>"; print "</TR>"; } print"</TABLE>"; mysql_free_result ($result); ?> Today's Date (according to the web server) is: <?php echo( date("F dS Y.") ); } else { echo "<a href=login.html>LOG-IN</a>"; } ?> -- 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 (#3697) next »