This is a simple project that demonstarates the use of Create Read Update Delete (CRUD) functionality with PHP. We use the PDO extension to connect to MySQL database. Additionally we use prepared statements to prevent against SQL injection attacks.
The project allows us to add, view, update and delete users.
In order to use this project, you need to have a server installed on your computer. I use XAMPP.
Start XAMPP and make sure both Modules Apache and MySQL are running.
In you browser go to localhost/phpmyadmin
Create a new database - test
Go to the SQL tab and paste the following query and click Go
CREATE TABLE `test`.`users` ( `id` INT UNSIGNED NOT NULL AUTO_INCREMENT , `username` VARCHAR(255) NOT NULL , `email` VARCHAR(255) NOT NULL , `password` VARCHAR(60) NOT NULL , PRIMARY KEY (`id`)) ENGINE = InnoDB;
Then perform the following steps
- Download the project
- Place it inside the htdocs folder of your XAMPP installation
- Make sure XAMPP is running (both Apache and MySQL)
- In your borwser of choice enter
localhost/pdo-basic-users-main
Enjoy