Note that there are some explanatory texts on larger screens.

plurals
  1. POPHP - User Management Delete Problem
    text
    copied!<p>I am working on a custom content management system. I was instructed to do some changes, and this is what I need to do. I need to create a user management page which allows the administrator to delete (or disable his status) a user from the database. </p> <p>This is my User Management Page:</p> <pre><code>&lt;?php $query = 'SELECT author_id, author_email as Email, author_name as Name FROM authors ORDER BY Name LIMIT 0, 30'; $result = mysql_query($query); ?&gt; &lt;table class="listing"&gt; &lt;thead&gt; &lt;tr&gt; &lt;td&gt;Author ID&lt;/td&gt; &lt;th&gt;Author E-Mail&lt;/th&gt; &lt;th&gt;Author Name&lt;/th&gt; &lt;th&gt;Delete&lt;/th&gt; &lt;/tr&gt; &lt;/thead&gt; &lt;tbody&gt; &lt;?php for ($i = 0; $row = mysql_fetch_array($result); $i++) { if ($i % 2 == 0) { echo '&lt;tr class="even"&gt;'; } else { echo '&lt;tr class="odd"&gt;'; } echo "&lt;td&gt;{$row['author_id']}&lt;/td&gt;"; echo "&lt;td&gt;{$row['Email']}&lt;/td&gt;"; echo "&lt;td&gt;{$row['Name']}&lt;/td&gt;"; echo "&lt;td&gt;&lt;a href=\"del-user.php?term={$row['author_id']}\" onclick=\"javascript:return confirm('Are you sure you want to delete this user?')\"&gt;X&lt;/a&gt;&lt;/td&gt;"; echo '&lt;/tr&gt;'; } ?&gt; &lt;/tbody&gt; &lt;/table&gt; </code></pre> <p>This is my del-user.php page: </p> <pre><code>&lt;?php include('inc/config.php'); $title = 'Delete Individual User'; include('inc/db.php'); include('inc/header.php'); echo '&lt;h2&gt;Delete&lt;/h2&gt;'; if (isset($GET['term'])) { $query = "DELETE FROM authors WHERE author_id = {$GET['term']} LIMIT 1"; mysql_query($query) or die('Failed to delete user'); echo '&lt;p&gt;User Deleted&lt;/p&gt;'; echo '&lt;p&gt;Back to &lt;a href="manage-users.php"&gt;Manage Users &lt;/&gt;.&lt;/p&gt;'; } else { echo '&lt;p&gt;Tried to Delete: "'; echo ($GET['term']); echo '"&lt;/p&gt;'; echo '&lt;p&gt;Nothing to Delete&lt;/p&gt;'; } include('inc/footer.php'); ?&gt; </code></pre> <p>I am new to PHP, but this is not working, the author_id value is not being passed to the other page, and it is being left empty. So I cannot delete anything from the del-users.php page.</p> <p>I'm guessing that this is the problematic part:</p> <pre><code>echo "&lt;td&gt;&lt;a href=\"del-user.php?term={$row['author_id']}\" onclick=\"javascript:return confirm('Are you sure you want to delete this user?')\"&gt;X&lt;/a&gt;&lt;/td&gt;"; </code></pre> <p>Anybody knows why this is happening?</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload