Jump to content

Help! Users with groups?


jsschmitt

Recommended Posts

Well your first step is done... having a list of your users in a users table.

 

Your next step is to have a groups table....having a list of all of your groups.

 

The last step (which is really a part of the first step) is to put a column within the users table to signify which group a particular user is in.  You would use the group's primary key for the value.

 

So.  if in your groups table.. the 3rd group was "Da Bears"  and in the users table you must have "Joe" in that group.  You would give Joe's group column a value of 3..    Get it? it's like number matching

Gah... Still lost..

 

Ok... Here is what I have..

 

Families:

ID    Name

1      Schmitt

 

Users:

id username first_name last_name family password

1  jschmitt          Schmitt          Schmitt          1          xxxxxxxxx

 

And the code I currently have..

 

<?php
session_start(); 
$sesuser = $_POST['username'];
$sespass = $_POST['password'];

include 'php/includes/dbconnect.php';

$query = "SELECT `username` , `family` FROM `users` WHERE `username` = '".$sesuser."' AND `password` = '".$sespass."' INNER JOIN `group` ON users.family = families.id";
$result = mysql_query($query) or die('Error, query failed');

if(mysql_num_rows($result)){
$_SESSION['username'] = $sesuser;
}

while ($row = mysql_fetch_array($result)) {
$_SESSION['family'] = $row['family'];
} 

include 'php/includes/closedb.php';

zheader('Location: http://anomymage.com/famshare/')
?>

 

Please... tell me what I am doing wrong!

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.