This is a simple PHP application to test the connectivity to a MySQL or PostgreSQL database. The user can provide database connection details through a form and check if the connection is successful or if there is any error.
- Database Type Selection: Choose between MySQL and PostgreSQL.
- Connection Test: Test the database connection based on the provided host, database name, username, and password.
- Error Handling: Displays specific error messages based on common database connection errors.
- Session Management: Once the connection is successful, the session is updated to reflect the connection status.
- PHP 7.0 or higher
- MySQL or PostgreSQL database
- Clone or download the repository to your local machine.
- Place the project files in your web server's directory (e.g.,
htdocs
for XAMPP). - Create a new database in either MySQL or PostgreSQL to test the connection.
- Start the local server and open
index.php
in your browser.
- When you open the application, you will see a form to enter your database connection details.
- Select the database type (MySQL or PostgreSQL), then provide the required details such as:
- Host (e.g.,
localhost
) - Database Name
- Username
- Password (optional)
- Host (e.g.,
- Click on Test Connection to check the database connectivity.
- If the connection is successful, a success message will appear along with a button to disconnect.
- If the connection fails, an error message will display the reason for the failure (e.g., incorrect username, database not found, etc.).


- Form Submission: The form is submitted via POST method to test the connection.
- Database Connection: Uses PDO (PHP Data Objects) for database interaction.
- Error Handling: Various database errors are handled by specific error codes and customized messages.
- Session Management: The connection status is stored in the session for the current session and can be checked by the user.
This project is open-source and available under the MIT License.
Feel free to fork this project and submit pull requests. If you find bugs or have suggestions for improvements, feel free to open an issue.
- Bootstrap for styling the UI components.
- PDO for database connections.
- Bootstrap Icons for the visual representation of success and failure.