Page 1 of 1

Login Script + add admin functions

Posted: Thu Jan 13, 2005 12:45 am
by Jim_Bo
Hi,

I have a login script working great .. I have been trying to make a admin form that will allow admin to:

show all users paginated with link to edit/delete users .. mostly to update user levels or delete unwanted members

maybe an option to delete inactive users by way of drop down menu with say 7, 14, 30, 100, 365 days.

data base table is layed out like:

Code: Select all

CREATE TABLE users (
  userid int(25) NOT NULL auto_increment,
  first_name varchar(25) NOT NULL default '',
  last_name varchar(25) NOT NULL default '',
  email_address varchar(25) NOT NULL default '',
  user_name varchar(25) NOT NULL default '',
  password varchar(255) NOT NULL default '',
  info text NOT NULL,
  user_level enum('0','1','2','3') NOT NULL default '0',
  signup_date datetime NOT NULL default '0000-00-00 00:00:00',
  last_login datetime NOT NULL default '0000-00-00 00:00:00',
  activated enum('0','1') NOT NULL default '0',
  PRIMARY KEY  (userid)
) TYPE=MyISAM COMMENT='Membership Information';
and dp.php:

Code: Select all

<? 
$dbhost = 'localhost';
$dbuser = '###';
$dbpasswd = '###';
$database = '###';

$connection = mysql_pconnect("$dbhost","$dbuser","$dbpasswd") 
	or die ("Couldn't connect to server.");
	
$db = mysql_select_db("$database", $connection)
	or die("Couldn't select database.");

?>
Any help on the most simple way to acheive this would be greatly appreciated.

Cheers

...

Posted: Thu Jan 13, 2005 1:11 am
by Calimero
Ok - first you need to design the interface - form in which you put all the functions (for each member ) or better yet in the page you list all your members ( and of course paginate them: first 10, 20, 30 ... ).

Create one layer on that page and put in it all the functions you need (add, edit, delete, crossreference, show status...)

// Note: for a layer to be visible no matter how "deep" down you are on the page - search for JavaScript and menus...

Now mainly about retreiving users from the DB - if you want to take 10 newest ( use date as comparison), 10 least active ( you need statistics to record coming to your site and code to analyse how long they were not visiting (date again - just switch the parameter 7, 15, 30, 60, 90, 180, 365(366) days )

When you have a list of users in the page - for each add one checkbox, so when you click on the checkbox a layer ( mentioned above ) with functions will apear and in it you assign each option as a variable. When you do what you want with that user you must have a submit button - to make your changes take effect. ( You will need a little JavaScript here - to show and hide the layer onSubmit )

Now the tricky part lays here - on the PHP side you need to create a php code that will take all the variables from the form in the layer and create an MySQL statement to insert parameters ( if you have already done this - its easy, but if not - play little with inserting variables in the mysql_query() function in PHP - but be carefull not to make errors in syntax in MySQL.


That's the way I would do it, if someone has a better idea ( for server side ) great - because this can maybe be done even better in JS and with just little PHP - but you have to have firm knowledge of JavaScript to play with this option.

Hope this helps.
See ya.