Jump to content

User Managment system??


avatar.alex

Recommended Posts

Hello I am in the process of creating or changing this user login system to a user management system. I would like to have the users in 3 levels of access:

1=member

2=mod

3=admin

I would like it so when they register they automatically go in the database as a member, but I would like a seperate registration page to like admins register??

This is the registration page. I would like it to be so when a momber registers it has them register as a member.

<?PHP

//Database Information

$dbhost = "localhost";
$dbname = "your database name";
$dbuser = "username";
$dbpass = "yourpass";

//Connect to database

mysql_connect ( $dbhost, $dbuser, $dbpass)or die("Could not connect: ".mysql_error());
mysql_select_db($dbname) or die(mysql_error());

    
$name = $_POST['name'];
$email = $_POST['email'];    
$username = $_POST['username'];
$password = md5($_POST['password']);

// lets check to see if the username already exists

$checkuser = mysql_query("SELECT username FROM users WHERE username='$username'");

$username_exist = mysql_num_rows($checkuser);

if($username_exist > 0){
    echo "I'm sorry but the username you specified has already been taken.  Please pick another one.";
    unset($username);
    include 'register.html';
    exit();
}

// lf no errors present with the username
// use a query to insert the data into the database.

$query = "INSERT INTO users (name, email, username, password)
VALUES('$name', '$email', '$username', '$password')";
mysql_query($query) or die(mysql_error());
mysql_close();

echo "You have successfully Registered";
    
// mail user their information

$yoursite = ‘killako.freehostia.com.com’;
$webmaster = ‘avatar.alex’;
$youremail = ‘avatar.alex@yahoo.com’;
    
$subject = "You have successfully registered at $yoursite...";
$message = "Dear $name, you are now registered at our web site.  
    To login, simply go to our web page and enter in the following details in the login form:
    Username: $username
    Password: $password
    
    Please print this information out and store it for future reference.
    
    Thanks,
    $webmaster";
    
mail($email, $subject, $message, "From: $yoursite <$youremail>\nX-Mailer:PHP/" . phpversion());
    
echo "Your information has been mailed to your email address.";

?>

 

This is part of the code that tells you if your logged in then you can view the page

 

if ( empty( $username ) ) {

    print "Please login below!";

    include 'login.html';

} else {

echo "Admins Only";
} if ($username=3)){
echo "Edit members here";
}
?>

 

The

if ($username=3)){
echo "Edit members here";
}

at the end I added if I get the system to work thats what I would what the user managment system to look like

 

I would like to store the PHP user level code in the connect.php with the connection to the database.

 

This is the table delow how would I add the userlvl in it? or would I make a new table because there are 3 user levels

CREATE TABLE users (
  userid int(25) NOT NULL auto_increment,
  name varchar(25) NOT NULL default '',
  email varchar(255) NOT NULL default '',
  username varchar(25) NOT NULL default '',
  password varchar(255) NOT NULL default '',
  PRIMARY KEY  (userid),
  UNIQUE KEY username (username)
) TYP

E=MyISAM COMMENT='Members';

 

 

Link to comment
Share on other sites

Erm.. OK

as YOU are in the process of creating or changing this user login system to a user management system.

 

why did you post here.. also i don't see the "Problem"..

 

were not here to do the work for you...!

try the freelance section

 

2. Don't ask someone to write or re-write a script for you, unless you are posting a message to the PHPFreelancing Forum.  The forums are not the place to request XYZ script.  This is a community of people learning PHP, and not a script location service.  Try searching sourceforge, phpclasses, hotscripts, or Google.
Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.