I have tried creating this delete fuction where a delete button will appear on each row f the table created. when it came to testing the delete button when it was clicked it looks like it was doing something but nothing happened it looked like it just reloaded the page and nothing else and it never deleted the chosen user id. I really think I am close to solving this problem.
here my code which I done:
<?php
if ($_POST['action'] == 'delete')
{
$sql = "DELETE FROM azizpassword WHERE user_id = {$_POST['user_id']}";
$conn = mysql_connect("localhost","root","") or die("Could Not Connect To The Database");
mysql_select_db("aziz",$conn) or die("Could Not Select The Database");
$result=mysql_query("SELECT user_id,az_firstname,az_surname,username FROM azizpassword ORDER BY user_id;");
$i=0;
while( $row=mysql_fetch_array($result) )
{
if($i>0)
{
echo "<tr valign=top>";
echo "<td bgcolor=#93B0B4 colspan=4></td>";
echo "</tr>";
}
echo "<tr valign=center>";
echo "<td width=100 class=table><b>".$row['user_id']."</b></td>";
echo "<td width=100 class=table><a href=\"view.php?id=".$row['user_id']."\">".$row['az_surname']."</a></td>";
echo "<td width=100 class=table>".$row['az_firstname']." </td>";
echo "<td width=100 class=table><i>".$row['username']."</i> </td>";
echo '<td width="100" class="table">'.
' <form action="" method="post">'.
' <input type="hidden" name="action" value="delete" />'.
' <input type="hidden" name="user_id" value="'.$row['user_id'].'" />'.
' <input type="submit" value="Delete" />'.
' </form>'.
'</td>';
echo "<td class=table></td>";
echo "</tr>";
$i++;
}
}
echo "<tr valign=bottom>";
echo "<td bgcolor=#93B0B4 colspan=6 height=8></td>";
echo "</tr>";
?>
I think we are really close to solving the problem but I just dunno what I may of done wrong I hope anyone can find the problem with my code and spot something I may have missed to allow me to delete the the chosen user.
Also I have had trouble with creating a warning messagewhich asks the user if they are sure the want to delete the user I would be really greatful if anyone can help me out with this problem too
Thank you for your time
Take Care