I'm writing an php script to approve users that registered on my page, but i'm facing a little problem when i want to approve them. Here's as far as i could get.
Table:
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("activation") or die(mysql_error());
//User Approval Script
$result2 = mysql_query("SELECT * FROM userinfo WHERE status='0'")
or die(mysql_error());
echo "<table border='1'>";
echo "<tr> <th>Name</th> <th>Action</th> <th>Hours</th> <th>Approve</th> </tr>";
while($row = mysql_fetch_array( $result2 )) {
// Print out the contents of each row into a table
echo "<tr><td>";
echo $row['first_name'];
echo "</td><td>";
echo $row['last_name'];
echo "</td>";
echo "<td>";
echo $row['email'];
echo "</td><td>";
echo "<form action=\"approve.php\" method=\"post\"><input name=\"approve[]\" type=\"checkbox\">";
echo "</td></tr>";
}
echo "</table>";
echo "<input type=\"submit\" value=\"Approve\"></form>";
?>
approve.php
<?php
mysql_connect("localhost", "root", "") or die(mysql_error());
mysql_select_db("activation") or die(mysql_error());
$ticked = $_POST['approve'];
foreach($ticked as $id) {
mysql_query("UPDATE status SET approved = '1' WHERE `ID` = '$id'");
}
unset($id);
?>
I would also like to know how i can send email to each user that is approved...
Thanks in advance everyone!
Edit:
The page on approve.php is all blank, and status isn't getting updated.