I'm trying to create an admin page where the admin must approve a user registration before the user logs in.I'm trying to show in this page all the users which have been registered but still waiting for admin approval for log in.So I want to create a button close to each unconfirmed user with the value"Yes" to give the admin the possibility to approve his account.If "Yes" button is set by the admin the user should be approved so the approval
field which is stored in my database should be updated to 1.This is the idea.When executing the code the buttons are displayed but no update is made for the field approval
!
Also the buttons are displayed but are not functional.Can someone help me to make the "Yes" buttons functional? This is my code:
<html >
<head>
<title></title>
</head>
<body>
<?php
if( !($database=mysql_connect("localhost","root",""))||!(mysql_select_db("st_login",$database)) )
print("Could not connect");
if(isset($_POST['yes'])){
$id = intval($_POST['id']);
$update_query= "UPDATE login SET `approval`=1 WHERE `id` = '".$id."'";
mysql_query($update_query,$database);
}
$query = "SELECT * FROM `login` WHERE `admin` =0";
if(!($result=mysql_query($query,$database)))
{
print("Could not execute query");
die (mysql_error());//ose error
} else
while($query_row=mysql_fetch_assoc($result))
{
$firstname=$query_row['firstname'];
$lastname=$query_row['lastname'];
$username=$query_row['username'];
$password=$query_row['password'];
$email=$query_row['email'];
$cv=$query_row['cv'];
$id=$query_row['id'];
if($query_row['approval']==0){
echo "this user is waiting for you approval";
echo $firstname.' '.$lastname.' has this cv:'.$cv.'<br />
Do you want to approve his account?
<form action="admin.php" method="post">
<input type="text" style="display: none;" value="$id" name="id">
<input type="submit" value="yes" name="yes">
</form>
<br/>';
}
}
mysql_close($database);
?>
</body>
</html>
Anyone helping me with this updating?Thanks in advance!