Anybody can help me with this?I would like to update the status of the user in the mysql database whether its disabled/enabled by inserting 0 or 1 through the edit page.

5 Years
Discussion Span
Last Post by eyeda


How to update the status of disable/enable account?

Can you explain it more in detail? It's a bit hard to help you if there's no MYSQL code. A code would be helpful.

Here is a link about Database:


But it would be helpful if you can explain more about it and provide a MYSQL query or table so we can assisted you.

Edited by LastMitch: grammer


Thank you LastMitch for replying. Here is my sql code.I want to update my user account status by enabling or disabling it with 0=disable,1=enable. The update code seem working for name,password,id and department except for the status. Is there anything wrong with the code or i need to find other code to make it work?



if (isset($_POST['submit']))

if (is_numeric($_POST['id']))

$id = $_POST['id'];
$name = $_POST['name'];
$password = $_POST['password'];
$email = $_POST['email'];
$department = $_POST['department'];

if ($id=='' || $name =='' || $password =='' || $email=='' || $department =='' || $status =='' )

$error = 'ERROR: Please fill in all required fields!';

valid($id, $name,$password, $email,$department,$status, $error);

mysql_query("UPDATE staff SET  enabled='$status',name='$name', password='$password', email='$email' , department='$department' WHERE id='$id'")
or die(mysql_error());

header("Location: display.php");

your query is fine. just check what you getting in POST array when you submit form place following code in the begining of your page after first php tag

echo "<pre>";
echo "</pre>";
die('stop to check post array');

I would make sure the id and status variables are defined as integers by doing this:

$id = (int) $_POST['id'];
$status = (int) $_POST['enabled'];

Then I would remove the apostrophe's from around the integers in your query:

mysql_query("UPDATE staff SET enabled = $status, name = '$name', password = '$password', email = '$email' , department = '$department' WHERE id = $id")

Other way of checking it is placing this code on line 34:

die("UPDATE staff SET  enabled='$status',name='$name', password='$password', email='$email' , department='$department' WHERE id='$id'");

which will echo your query and halt the sript. Now you can examine the query and/or test it in phpmyadmin.


Thank you guys for all the helps! I've tried all of it,but still its not solving my problems.I've solve it by seperating the status updating activities and make it as a one module.

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.