Jump to content

Disabling and enabling users


taz321

Recommended Posts

Hi there, i am creating a help desk system using PHP, MySQL and i have an admin part of the system which adds, deletes and updates users to the system.

But instead of deleting the users i want to be able to disable them and then re-enable them instead of deleting as i would lose their details and would have to add the users again. This i feel would save me time.

 

This is the delete script.

 

<?php

require "connect.php";

$employeeID = $_GET['employeeID'];

$query =  "delete from employee where employeeID = ".$employeeID;

$result = mysql_query($query, $connection)

or die ("Unable to perform query<br>$query");

header("Location: displayEmployeeAdmin.php");

exit();

?>

 

And this is the script which reads the above when i delete a user.

 

<td width="130"><div align="center" class="style7"><a href="EditUserForm.php?employeeID=<?php echo $row['employeeID'];?>"><?php echo $row['firstname'];?></div></td>

    <td width="130"><div align="center" class="style7"><?php echo $row['surname'];?></div></td>

    <td width="130"><div align="center" class="style7"><?php echo $row['username'];?></div></td>

    <td width="130"><div align="center" class="style7"><?php echo $row['password'];?></div></td>

<td><a href="deleteUser.php?employeeID=<?php echo $row['employeeID'];?>">[delete]</a></td>

 

 

The actual deleting of the user is on the last line of the above script.

 

Can anyone help me with the disable and re-able code ?

 

Any Help be appreciated.

 

Thanks

 

Link to comment
https://forums.phpfreaks.com/topic/83254-disabling-and-enabling-users/
Share on other sites

Well your DB Table

 

Users

  username    active

        test        1

 

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

 

if($active == 1){

echo "Welcome user";

} else {

echo "Sorry this account is inactive";

}

 

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.