![]() |
| Screen-1:Active or De-active account |
![]() | |
|
![]() |
| Screen-3:De active account |
Download:
Active and De active account
u can use select query where condition status=1 in user panel
Database:
CREATE DATABASE `demo` DEFAULT CHARACTER SET latin1 COLLATE latin1_swedish_ci;USE `demo`;
CREATE TABLE IF NOT EXISTS `user_mangement` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`username` varchar(50) NOT NULL,
`status` int(1) NOT NULL,
PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=latin1 AUTO_INCREMENT=5 ;
INSERT INTO `user_mangement` (`id`, `username`, `status`) VALUES
(1, 'Pandi', 1),
(2, 'Karthi', 0),
(3, 'Ram', 1),
(4, 'Arun', 1);
index.php
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Active and Deactive</title> </head> <style> body { background:url(images/bg.jpg); text-align:center; margin-top:200px; font-family:Tahoma, Geneva, sans-serif; } th { height:40px; color:#000; font-weight:bold; } td { color:#FFF; height:30px; } a { color:#FFF; text-decoration:none; } a:hover { color:#FFF; text-decoration:underline; } </style> <body> <table width="27%" border="1" align="center" cellpadding="0" cellspacing="0"> <tr> <th width="43%" scope="col">User Name</th> <th width="57%" scope="col">Status</th> </tr> <?php $conn=mysql_connect("localhost","root","") or die(mysql_error()); $sdb=mysql_select_db("demo",$conn) or die(mysql_error()); $select=mysql_query("select * from user_mangement"); while($user=mysql_fetch_array($select)) { $id=$user['id']; $username=$user['username']; $status=$user['status']; ?> <tr> <td><?php echo $username?></td> <td> <?php if(($status)=='0') { ?> <a href="status.php?status=<?php echo $user['id'];?>" onclick="return confirm('Really you activate (<?php echo $username?>)');"> <img src="images/deactivate.png" id="view" width="16" height="16" alt="" />Deactivated </a> <?php } if(($status)=='1') { ?> <a href="status.php?status=<?php echo $user['id'];?>" onclick="return confirm('Really you De-activate (<?php echo $username?>)');"> <img src="images/activate.png" width="16" id="view" height="16" alt="" />Activated</a> <?php } ?></td> <?php }?> </tr> </table> </body> </html>
status.php
<?php $conn=mysql_connect("localhost","root","") or die(mysql_error()); $sdb=mysql_select_db("demo",$conn) or die(mysql_error()); if(isset($_GET['status'])) { $status=$_GET['status']; $select_status=mysql_query("select * from user_mangement where id='$status'"); while($row=mysql_fetch_object($select_status)) { $st=$row->status; if($st=='0') { $status2=1; } else { $status2=0; } $update=mysql_query("update user_mangement set status='$status2' where id='$status' "); if($update) { header("Location:index.php"); } else { echo mysql_error(); } } ?> <?php } ?>



Nice post..
ReplyDeleteThank u Mr.Arun
Delete