The User Management API is a RESTful API that allows for the management of user accounts. It supports CRUD (Create, Read, Update, Delete) operations and is built using PHP and MySQL. This API can be used to create new users, retrieve user information, update existing users, and delete users.
- Create new user accounts
- Retrieve user information (single and all users)
- Update user details, including username, email, and password
- Delete user accounts
- PHP
- MySQL
- HTML/CSS
- JavaScript (with Fetch API)
- A local server environment (e.g., XAMPP, WAMP, or MAMP) to run PHP and MySQL.
- A web browser to access the frontend.
-
Clone the Repository
git clone https://github.com/RBalajisrinath/User_Management_API cd user_management_api -
Set Up the Database
- Open phpMyAdmin (usually accessible at
http://localhost/phpmyadmin). - Create a new database named
user_management. - Run the following SQL command to create the
userstable:CREATE TABLE users ( id INT AUTO_INCREMENT PRIMARY KEY, username VARCHAR(50) NOT NULL, email VARCHAR(100) NOT NULL, password VARCHAR(255) NOT NULL );
- Open phpMyAdmin (usually accessible at
-
Configure the API
- Open
src/backend/api.phpand ensure the database connection parameters are correct:$mysqli = new mysqli("localhost", "root", "", "user_management");
- Open
-
Start the Local Server
- Start your local server (e.g., XAMPP, WAMP, or MAMP) and ensure Apache and MySQL services are running.
-
Access the Application
- Open your web browser and navigate to
http://localhost/user_management_api/frontend/index.html.
- Open your web browser and navigate to
- Method: GET
- URL:
http://localhost/user_management_api/src/backend/api.php - Response: JSON array of all users.
- Method: GET
- URL:
http://localhost/user_management_api/src/backend/api.php?id={user_id} - Response: JSON object of the user with the specified ID.
- Method: POST
- URL:
http://localhost/user_management_api/src/backend/api.php - Body: JSON object
{ "username": "newuser", "email": "newuser@example.com", "password": "password123" } - Response: JSON message indicating success.
- Method: PUT
- URL:
http://localhost/user_management_api/src/backend/api.php?id={user_id} - Body: JSON object
{ "username": "updateduser", "email": "updateduser@example.com", "password": "newpassword123" } - Response: JSON message indicating success.
- Method: DELETE
- URL:
http://localhost/user_management_api/src/backend/api.php?id={user_id} - Response: JSON message indicating success.
You can use tools like Postman to interact with the API endpoints. Follow the instructions in the "Connect it with Postman" section to test the API.