Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8436771
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T07:16:22+00:00 2026-06-10T07:16:22+00:00

I’m using php and mysql to develop an application; A little background data about

  • 0

I’m using php and mysql to develop an application; A little background data about it,it’s a login system which stores usernames and passwords and all the works that a login system does. However I have ran into a problem when it comes to deleting users, the function for deleting users works fine but the problem is For example the administrator can delete himself leaving the database with no user. So what I would want to do is when I am on the main page, a function runs to check if a specific username exists

//Example:
Table name: users
columns: username, password
default username and password I want to always remain in table 'users'
username=dames and password=:password 
//End of Example

and if not add the username and password and also if the default username and password has been updated it inserts the default username and password, and and not deleting the updated one.
I hope I made it clear enough because id really appreciate some help and suggestions.Thanks

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T07:16:23+00:00Added an answer on June 10, 2026 at 7:16 am

    If you want to make sure that at least one administrator is always present, only delete the administrator if another one is still present:

    DELETE
      u1
    FROM
      user u1
    LEFT JOIN
      user u2
    ON
      u1.access = u2.access
    WHERE
      u1.name = "current-user" AND
      ((u1.name != u2.name AND u1.access = "admin") OR (u1.access != "admin"));
    

    The given query above expects a table with a username (name) and an access level (access). It matches the user “current-user”, but only if there is another user with the access level “admin”. If “current-user” itself has not access level “admin”, it is matched anyway.

    This way, you just need to create one user with “admin” access level once. More users can be added and deleted, just not the very last user with “admin” access level.

    If you want to do everything in SQL, you can create a BEFORE DELETE TRIGGER. There, you simply check for the usernames you do not want to be deleted. See How to abort INSERT operation in MySql trigger? for an example – it is given for INSERT, but works the same for DELETE.

    Then again, it really depends on your setup if you want to use configuration files (as suggested) or database logic to customise your application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I am reading a book about Javascript and jQuery and using one of the
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I want to count how many characters a certain string has in PHP, but
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm new to using the Perl treebuilder module for HTML parsing and can't figure
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I would like to count the length of a string with PHP. The string
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.