Webocreation

Monday, February 8, 2010

delete user from the database

<?php
$user_id=$_GET['user_id'];

if(isset($_GET['submit']))
{

if (mysql_connect("localhost","root",""))
{
//echo "connected";
mysql_select_db("php_classes");

$confirm=$_GET['confirm'];

if ($confirm==1)
{


$query="delete from profile where user_id=$user_id limit 1";
//echo $query;

$result=mysql_query($query);

if (mysql_affected_rows()==1)
{
echo "User of ID $user_id has been deleted ";
}
else
{
echo "User of ID $user_id has NOT been deleted";
}

}
else
{
echo "The action was not done";
}


}
else
{
echo "Could not connect to database";
}



}




?>

<form method="get" action="delete_user.php">
Deleting user <?php echo $user_id; ?>
<input type="hidden" name="user_id" value="<?php echo $user_id; ?>" /><br/>
<input type="radio" name="confirm" value="0" checked="checked"/>No   <input type="radio" name="confirm" value="1"/>Yes<br/>

<input type="submit" name="submit" value="Do Action"/>
</form>

delete user from the database, delete with the confirm from the database, delete and confirm in the same page

No comments:

Post a Comment