I copied a code from another form which was in percentages, I made a text box where it says by default activated, but if you put something else and submit it changes the row “active” in mysql, and another script checks if it says something else then activated then it will not make him loginable and displays the message u wrote.
So I just need to make it change the row active when I submit, but it echoes the successfull message but doesn’t update anything.
<?php
if (isset($_POST['Submit'])) {
$percentage = round($_POST['active']);
if ((!empty($_POST['active']))) {
mysql_query("UPDATE users SET active = '$percentage' WHERE id='1'") or die("MYSQL is indeed gay: ".mysql_error());
}
echo 'Status updated';
} //If Submit
?>
<?php
if (isset($_POST['Submit'])) {
$active_v = ($_POST['active']);
if ((!empty($_POST['active']))) {
mysql_query("UPDATE users SET active = '$active_v' WHERE id='1'") or die("MYSQL is indeed gay: ".mysql_error());
}
echo 'Status updated';
} //If Submit
?>
That will update the mysql record for user 1 and set active to whatever you type in the form.
Oh if this isn’t a number then let’s not forget to escape that!
<?php
if (isset($_POST['Submit'])) {
$active_v = mysql_real_escape_string($_POST['active']);
if ((!empty($_POST['active']))) {
mysql_query("UPDATE users SET active = '$active_v' WHERE id='1'") or die("MYSQL is indeed gay: ".mysql_error());
}
echo 'Status updated';
} //If Submit
?>
Echo the query and run it directly in MySQL to see what is going on easily.
If the condition fails than it has something to with either the value not existing in the post or perhaps it is a 0. If the value is a 0 than empty() will be true, hence the condition will fail.