Mutplie Queries in same script?!
Posted: Mon Dec 30, 2002 5:17 pm
Hi,
Due to the kind of site I am in I have user levels and I need these broken down even further like 1-3 is one group 4-6 is another group and 7-10 is yet another group. I have 4 tables to handle of this broken down in such a way that 1 DB contains the primary login data for <b>ALL</B> users, such as user name, password (encrypted of course), and ID and whther they are logged in or not...
the other 3 tables contain information specific to the type of account, which are:
...
$name is defined, it is what was passed by the form, that is handled up above and is working properly...amaing isn't it?! hehe...
Thanks alot folks!
Due to the kind of site I am in I have user levels and I need these broken down even further like 1-3 is one group 4-6 is another group and 7-10 is yet another group. I have 4 tables to handle of this broken down in such a way that 1 DB contains the primary login data for <b>ALL</B> users, such as user name, password (encrypted of course), and ID and whther they are logged in or not...
the other 3 tables contain information specific to the type of account, which are:
- Children
- Parents and Teachers
- Site Staff/Volunteers
Code: Select all
<?
$connection = mysql_connect("$host","$sqluser","$pass");
if ($connection == false) {
echo mysql_errno . ": " . mysql_error() . "<br>";
exit;
}
mysql_select_db('kidstop');
// now uses m_login which will check user level and grab info from
// appropriate table to register into the session...
$query = "SELECT * FROM m_login WHERE u_name = '$name'";
$result = mysql_query($query);
if ($row = mysql_fetch_array($result)) {
if ($name == $row["u_name"]) {
if (md5($pass1) == $row["u_pass"]) {
$ulvl = $row["u_level"];
mysql_free_result($result);
if ( $ulvl << 3 ) {
$query = "SELECT * FROM k_main WHERE u_name = '$name'";
$result = mysql_query($query);
$login = $row;
}
if ( $ulvl >> 3 && $row["u_level"] << 7 ) {
$query = "SELECT * FROM p_login WHERE u_name = '$name'";
$result = mysql_query($query);
$login = $row;
}
if ( $ulvl >> 7) {
$query = "SELECT * FROM staff WHERE u_name = '$name'";
$result = mysql_query($query);
$login = $row;
}
session_register('login'); // Now called after all DB calls have been parsed to make sure we have coorect info for acocunt type.
echo "<BR>You are now logged in! <A HREF="index.php">Click Here</A> to continue!<BR>";
?>Thanks alot folks!