I have an user table like this:-
guid | username | password | firstname | lastname | location | emailaddress | userrole
-----------------------------------+----------+----------------------------------+-----------+-----------+----------+--------------+---------------
8024259764dc3e8ee0fb6f5.84107784 | james | 827ccb0eea8a706c4c34a16891f84e7b | james | bond | NY | ny@live.com | administrator
18689183644dc3e91571a364.71859328 | saty | 250cf8b51c773f3f8dc8b4be867a9a02 | saty | john | NY | hk@fd.com | administrator
2644885344cecd6f2973b35.63257615 | admin | 21232f297a57a5a743894a0e4a801fc3 | System | Generated | | | administrator
(3 rows)
now my postgre query for delete the row ….
$query = "delete from users where username!= 'admin' and guid='".$guid."'";
$result = pg_query($conn, $query);
?>
<script type="text/javascript">
alert("Cannot delete this .\n It is system generated(s).");
</script>
<?php
when someone try to delete username from my page userlist.php .. this alert generate for only for admin and continue on this page..and also admin never delete it is default …
otherwise delete the data from database except admin
help me
Why not lookup the username for the
$guidbefore you try to delete anything, just a simple bit of SQL like this:Then, if
usernameis “admin”, show your alert; if thereusernameis not “admin”, do your deletion. You seem to be trying to do too many different things at the same time when you should be doing things one at a time, there’s nothing wrong with doing two queries when you need to do two different things.And I hope your sanitizing and quoting
$guidsomewhere to prevent SQL injection issues.