Ok i have code that can display the users that have been entered into the database, which uses a loop. Inside that loop i have created delete buttons so that the user can delete one of them. The problem is that i cannot pass the $id of just the user to be deleted, instead it passes them all through and no matter which you pick, the last is always chosen to be deleted.
Here is what ive done:
Code:
<?php
include('verifyuser.php');
?>
<html>
<body>
<?php
if(isset($_SESSION['valid_user'])){
echo "<b>Welcome back " .$_SESSION['valid_user']. "<center><br></b>";
$query="select * from users";
$result=mysql_query($query) or die ("Error in query");
echo'<form action="deleteuser2.php" method="GET">';
echo'<table><tr><th>ID</th><th>User</th><th></th></tr>';
while($row=mysql_fetch_array($result)){
echo '<tr><td>'.stripslashes($row['id']);
$delete=stripslashes($row['id']);
echo'<input type="hidden" name="id" value="'.$delete.'"</td>';
<?php
include('verifyuser.php');
?>
<html>
<body>
<?php
if(isset($_SESSION['valid_user'])){
echo "<b>Welcome back " .$_SESSION['valid_user']. "<center><br></b>";
$query="select * from users";
$result=mysql_query($query) or die ("Error in query");
echo'<form action="deleteuser2.php" method="GET">';
echo'<table><tr><th>ID</th><th>User</th><th></th></tr>';
while($row=mysql_fetch_array($result)){
echo '<tr><td>'.stripslashes($row['id']);
$delete=stripslashes($row['id']);
echo'<input type="hidden" name="id" value="'.$delete.'"</td>';
echo '<td>'.stripslashes($row['userid']);
$userid=$row['userid'];
echo '</td><td><input type="submit" value="Delete"</td></tr>';
}
echo"<a href='adminmenu.php'>Administration menu</a>";
}
else{
echo"Please login to view this page<br>";
echo"<a href='authmain.php'>Login</a>";}
?>
</table>
</form>
</html>
echo '<td>'.stripslashes($row['userid']);
$userid=$row['userid'];
echo '</td><td><input type="submit" value="Delete"</td></tr>';
}
echo"<a href='adminmenu.php'>Administration menu</a>";
}
else{
echo"Please login to view this page<br>";
echo"<a href='authmain.php'>Login</a>";}
?>
</table>
</form>
</html>