{"id":16601591,"url":"https://github.com/amankumarsinhagithub/crud-app-using-php-mysql","last_synced_at":"2025-04-15T21:24:45.996Z","repository":{"id":220197337,"uuid":"749422937","full_name":"AmanKumarSinhaGitHub/CRUD-App-using-PHP-MySQL","owner":"AmanKumarSinhaGitHub","description":"This repository showcases a simple CRUD (Create, Read, Update, Delete) application implemented in PHP and MySQL.","archived":false,"fork":false,"pushed_at":"2024-02-05T17:46:57.000Z","size":246,"stargazers_count":5,"open_issues_count":0,"forks_count":5,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-03-29T01:34:00.636Z","etag":null,"topics":["backend","bootstrap5","crud-application","database","html-css-javascript","mysql","php"],"latest_commit_sha":null,"homepage":"https://php-mysql-crud-app.000webhostapp.com","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/AmanKumarSinhaGitHub.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-01-28T14:46:32.000Z","updated_at":"2025-03-04T06:15:41.000Z","dependencies_parsed_at":"2024-11-16T15:04:16.089Z","dependency_job_id":null,"html_url":"https://github.com/AmanKumarSinhaGitHub/CRUD-App-using-PHP-MySQL","commit_stats":null,"previous_names":["amankumarsinhagithub/crud-app-using-php-mysql"],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmanKumarSinhaGitHub%2FCRUD-App-using-PHP-MySQL","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmanKumarSinhaGitHub%2FCRUD-App-using-PHP-MySQL/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmanKumarSinhaGitHub%2FCRUD-App-using-PHP-MySQL/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/AmanKumarSinhaGitHub%2FCRUD-App-using-PHP-MySQL/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/AmanKumarSinhaGitHub","download_url":"https://codeload.github.com/AmanKumarSinhaGitHub/CRUD-App-using-PHP-MySQL/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":249155534,"owners_count":21221620,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["backend","bootstrap5","crud-application","database","html-css-javascript","mysql","php"],"created_at":"2024-10-12T00:18:37.004Z","updated_at":"2025-04-15T21:24:45.975Z","avatar_url":"https://github.com/AmanKumarSinhaGitHub.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"﻿# CRUD-App-using-PHP-MySQL\r\n\r\n\r\n### [Live Preview - Click to Open](https://php-mysql-crud-app.000webhostapp.com)\r\n\r\n![Preview](https://github.com/AmanKumarSinhaGitHub/CRUD-App-using-PHP-MySQL/assets/65329366/918d0190-eb7a-49f2-98ac-fd8add2c5f01)\r\n\r\n![Preview](https://github.com/AmanKumarSinhaGitHub/CRUD-App-using-PHP-MySQL/assets/65329366/9eb94df4-cd39-41af-95b5-5d3a54232230)\r\n\r\n\r\nBefore you begin, make sure you have the following installed:\r\n\r\n- PHP\r\n- MySQL\r\n- Web server (e.g., Apache)\r\n- A web browser\r\n\r\n## Setup Database\r\n\r\n1. **Create a Database:**\r\n\r\n   - Open your MySQL database management tool (e.g., phpMyAdmin).\r\n\r\n   - Create a new database named `crud`.\r\n\r\n   - If you are using phpMyAdmin, follow these steps:\r\n     - Click on the \"Databases\" tab.\r\n     - Enter `crud` in the \"Database name\" field.\r\n     - Click the \"Create\" button.\r\n\r\n2. **Create a Table:**\r\n\r\n   - Inside the `crud` database, create a table named `userdetails` using the following SQL query:\r\n\r\n   ```sql\r\n   CREATE TABLE `userdetails` (\r\n     `id` int(11) NOT NULL AUTO_INCREMENT,\r\n     `name` varchar(255) NOT NULL,\r\n     `email` varchar(255) NOT NULL,\r\n     `mobile` varchar(15) NOT NULL,\r\n     `password` varchar(255) NOT NULL,\r\n     PRIMARY KEY (`id`)\r\n   );\r\n   ```\r\n\r\n3. **Using a MySQL Database Management Tool (e.g., phpMyAdmin):**\r\n\r\n   - Open phpMyAdmin or any other MySQL database management tool you are using.\r\n\r\n   - Select the database where you want to create the table (in this case, `crud`).\r\n\r\n   - Navigate to the \"SQL\" tab or equivalent.\r\n\r\n   - Copy and paste the provided SQL query into the input box.\r\n\r\n   - Click the \"Go\" or \"Execute\" button to run the query.\r\n\r\n   Example:\r\n\r\n   ```sql\r\n   CREATE TABLE `userdetails` (\r\n     `id` int(11) NOT NULL AUTO_INCREMENT,\r\n     `name` varchar(255) NOT NULL,\r\n     `email` varchar(255) NOT NULL,\r\n     `mobile` varchar(15) NOT NULL,\r\n     `password` varchar(255) NOT NULL,\r\n     PRIMARY KEY (`id`)\r\n   );\r\n   ```\r\n\r\n   This will create the `userdetails` table with the specified structure in the `crud` database.\r\n\r\n# Data Insertion\r\n\r\n```php\r\n\u003c?php\r\n// Database connection parameters\r\n$servername = \"localhost\";\r\n$username = \"root\";\r\n$password = \"\";\r\n$database = \"crud\";\r\n\r\n// Create a connection to the database\r\n$conn = new mysqli($servername, $username, $password, $database);\r\n\r\n// Check if the database connection is successful\r\nif (!$conn) {\r\n  die(\"Connection Error\". mysqli_error($conn));\r\n}\r\n\r\n// Check if the form is submitted using the POST method\r\nif (isset($_POST[\"submit\"])) {\r\n\r\n  // Retrieve user inputs from the form\r\n  $name = $_POST['name'];\r\n  $email = $_POST['email'];\r\n  $mobile = $_POST['mobile'];\r\n  $password = $_POST['password'];\r\n\r\n  // Validate if all fields are filled\r\n  if (empty($name) || empty($email) || empty($mobile) || empty($password)) {\r\n    echo \"All fields are required\";\r\n  } else {\r\n    // Construct SQL query to insert data into the 'userdetails' table\r\n    $sql = \"INSERT INTO `userdetails` (`name`, `email`, `mobile`, `password`) VALUES ('$name', '$email', '$mobile', '$password')\";\r\n\r\n    // Execute the SQL query\r\n    $result = mysqli_query($conn, $sql);\r\n\r\n    // Check if the query execution was successful\r\n    if ($result) {\r\n      echo \"New record created successfully\";\r\n    } else {\r\n      die(mysqli_error($conn));\r\n    }\r\n  }\r\n}\r\n\r\n// Close the database connection\r\n$conn-\u003eclose();\r\n?\u003e\r\n\r\n\r\n\u003c!doctype html\u003e\r\n\u003chtml lang=\"en\"\u003e\r\n\r\n\u003chead\u003e\r\n  \u003cmeta charset=\"utf-8\"\u003e\r\n  \u003cmeta name=\"viewport\" content=\"width=device-width, initial-scale=1\"\u003e\r\n  \u003ctitle\u003eCRUD App using PHP MySQL\u003c/title\u003e\r\n  \u003clink href=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/css/bootstrap.min.css\" rel=\"stylesheet\" integrity=\"sha384-T3c6CoIi6uLrA9TneNEoa7RxnatzjcDSCmG1MXxSR1GAsXEV/Dwwykc2MPK8M2HN\" crossorigin=\"anonymous\"\u003e\r\n\u003c/head\u003e\r\n\r\n\u003cbody\u003e\r\n\r\n  \u003cstyle\u003e\r\n    html,\r\n    body {\r\n      background-color: gainsboro;\r\n    }\r\n  \u003c/style\u003e\r\n\r\n  \u003cdiv class=\"container py-5 px-5\"\u003e\r\n\r\n    \u003cdiv class=\"container text-center py-3\"\u003e\r\n      \u003ch2\u003eCRUD OPERATIONS\u003c/h2\u003e\r\n    \u003c/div\u003e\r\n\r\n    \u003c!-- Form with POST method to submit data to PHP --\u003e\r\n    \u003cform method=\"post\"\u003e\r\n\r\n      \u003cdiv class=\"mb-3\"\u003e\r\n        \u003clabel for=\"name\" class=\"form-label\"\u003eName\u003c/label\u003e\r\n        \u003cinput type=\"name\" class=\"form-control\" name=\"name\" id=\"name\" placeholder=\"Enter Your Name\"\u003e\r\n      \u003c/div\u003e\r\n\r\n      \u003cdiv class=\"mb-3\"\u003e\r\n        \u003clabel for=\"email\" class=\"form-label\"\u003eEmail address\u003c/label\u003e\r\n        \u003c!-- 'name' attribute is used to identify this input field in PHP --\u003e\r\n        \u003cinput type=\"email\" class=\"form-control\" name=\"email\" id=\"email\" placeholder=\"Enter Your Email address\" aria-describedby=\"emailHelp\"\u003e\r\n      \u003c/div\u003e\r\n\r\n      \u003cdiv class=\"mb-3\"\u003e\r\n        \u003clabel for=\"mobile\" class=\"form-label\"\u003eMobile Number\u003c/label\u003e\r\n        \u003cinput type=\"number\" class=\"form-control\" name=\"mobile\" id=\"mobile\" placeholder=\"Enter Your Mobile Number\"\u003e\r\n      \u003c/div\u003e\r\n\r\n      \u003cdiv class=\"mb-3\"\u003e\r\n        \u003clabel for=\"password\" class=\"form-label\"\u003ePassword\u003c/label\u003e\r\n        \u003cinput type=\"password\" class=\"form-control\" name=\"password\" id=\"password\" placeholder=\"Enter Your Password\"\u003e\r\n      \u003c/div\u003e\r\n\r\n      \u003cbutton type=\"submit\" name=\"submit\" class=\"btn btn-primary\"\u003eSubmit\u003c/button\u003e\r\n    \u003c/form\u003e\r\n  \u003c/div\u003e\r\n\r\n  \u003cscript src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.3.2/dist/js/bootstrap.bundle.min.js\" integrity=\"sha384-C6RzsynM9kWDrMNeT87bh95OGNyZPhcTNXj1NW7RuBCsyN/o0jlpcV8Qyq46cDfL\" crossorigin=\"anonymous\"\u003e\u003c/script\u003e\r\n\u003c/body\u003e\r\n\r\n\u003c/html\u003e\r\n```\r\n\r\n#### Checkout More Branches for Fetching Data, Editing Data, and Deleting Data from Database.\r\n\r\n## Insert Data\r\n```bash\r\ngit checkout main\r\n```\r\n\r\n## Fetch Data\r\n```bash\r\ngit checkout read-data\r\n```\r\n\r\n## Delete Data\r\n```bash\r\ngit checkout delete-data\r\n```\r\n\r\n## Update Data\r\n```bash\r\ngit checkout update-data\r\n```\r\n\r\n## Crud Operations with Images\r\n```bash\r\ngit checkout crud-with-images\r\n```\r\n\r\n\r\n# More\r\nUpload Img in DB and Display it\r\n[Repo Link](https://github.com/AmanKumarSinhaGitHub/Image-Upload-and-Display-using-PHP-MySQL)\r\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famankumarsinhagithub%2Fcrud-app-using-php-mysql","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Famankumarsinhagithub%2Fcrud-app-using-php-mysql","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Famankumarsinhagithub%2Fcrud-app-using-php-mysql/lists"}