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.

Recommended Answers

All 6 Replies

Member Avatar for LastMitch

@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:

http://webmaster.iu.edu/tools-and-guides/mysql/privileges.phtml

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

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?

<?php
}

include('config.php');

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

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

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



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

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


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

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

<?php
echo "<pre>";
print_r($_POST);
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.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.