Jump to content

Recommended Posts

[code][code]

ok... i need help.. i have this form that'll try to delete a user from Login.php

 

/* Get data. */
$sql = "SELECT * FROM Login ORDER BY id";
$result = mysql_query($sql);
echo "
<TABLE BORDER=4 CELLPADDING=2  CELLSPACING=2 WIDTH=100%>";
while ($row = mysql_fetch_assoc($result)) {
$userrow = $row['userid'];
    echo "
<TR>
<TD>" . $row['username'] . "</TD>
<TD>" . $row['id'] . "</TD>
<TD> <form method = post action = ../deleteUser.php >

<input type=hidden  name=hiddenid2 value=$userrow />

<input type = submit name=submitdelete value=delete />
</form></TD>
</TR>
";
}
echo "</TABLE>";

here's deleteUser.php

<?php
mysql_connect(nah nah nah) or die(mysql_error
    ());
mysql_select_db(kokokoko) or die(mysql_error());

mysql_query("DELETE FROM Login WHERE id='$_POST[hiddenid2]'");
header('location: ../addUser.php');
?>

but when i press the button in the first form it delete's all users!!!!! i need help[/code][/code]

Link to comment
https://forums.phpfreaks.com/topic/112349-solved-delete-a-user/
Share on other sites

It is doing that because you are selecting ALL the users

$sql = "SELECT * FROM Login ORDER BY id";

and displaying all of the users (including hidden id's) in the table.

 

You can either limit the users returned (LIMIT #) or re-arrange your script. I would add a checkbox beside each username and have the checkbox's value as the id. Then you set the script up that it will only delete the users that have been checked. Make sense?

Link to comment
https://forums.phpfreaks.com/topic/112349-solved-delete-a-user/#findComment-576825
Share on other sites

It is doing that because you are selecting ALL the users

$sql = "SELECT * FROM Login ORDER BY id";

and displaying all of the users (including hidden id's) in the table.

 

You can either limit the users returned (LIMIT #) or re-arrange your script. I would add a checkbox beside each username and have the checkbox's value as the id. Then you set the script up that it will only delete the users that have been checked. Make sense?

well first off... i wanna show all users... and have a delete button for each!

Link to comment
https://forums.phpfreaks.com/topic/112349-solved-delete-a-user/#findComment-576828
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.