taz321 Posted December 26, 2007 Share Posted December 26, 2007 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 More sharing options...
revraz Posted December 26, 2007 Share Posted December 26, 2007 Have a field named "active". Set it to either 0/1 or yes/no. Then you can change whether they are active or not. Or call it "disabled", whichever you prefer. Link to comment https://forums.phpfreaks.com/topic/83254-disabling-and-enabling-users/#findComment-423503 Share on other sites More sharing options...
taz321 Posted December 26, 2007 Author Share Posted December 26, 2007 Sorry im feeling abit stupid now :-) but what would the code for that look like ? Link to comment https://forums.phpfreaks.com/topic/83254-disabling-and-enabling-users/#findComment-423505 Share on other sites More sharing options...
drummer101 Posted December 26, 2007 Share Posted December 26, 2007 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"; } Link to comment https://forums.phpfreaks.com/topic/83254-disabling-and-enabling-users/#findComment-423537 Share on other sites More sharing options...
taz321 Posted December 26, 2007 Author Share Posted December 26, 2007 Thanks, il play around with it and see where i get. Much appreciated Link to comment https://forums.phpfreaks.com/topic/83254-disabling-and-enabling-users/#findComment-423748 Share on other sites More sharing options...
drummer101 Posted December 26, 2007 Share Posted December 26, 2007 No problem Link to comment https://forums.phpfreaks.com/topic/83254-disabling-and-enabling-users/#findComment-423754 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.