View Full Version : creating an alert and continue on this page after alert for admin only

05-07-2011, 08:48 AM
I have an user table like this:-

guid | username | password | firstname | lastname | location | emailad
dress | userrole
8024259764dc3e8ee0fb6f5.84107784 | james | 827ccb0eea8a706c4c34a16891f84e7b | james | bond | NY | ny@live
.com | administrator
18689183644dc3e91571a364.71859328 | saty | 250cf8b51c773f3f8dc8b4be867a9a02 | saty | john | NY | hk@fd.c
om | 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).");

(1)when I delete the user name one by one then delete occurs in my page userlist.php, I donot want to delete admin so i use username!= 'admin'

in where condition as shown above.
(2)now when I del any username(3 rows) from user table then alert occurs & it delete from userlist.php after that my page userlist.php is

blank. Finaly when i refresh the page then my admin username seen..

when i use return true; function then only alert generate .. delete doesnot occurs ...

Actauly i want:-
(1)if user is not admin then it delete from userlist.php ... nd also i m continue on this page ... like when james and saty want

to delte their acount ..as given in table.
(2)if user is admin then alert generate nd i m continue on this page.

i m tired now plz help me ....

so can anyone put the best condition in my coding.