Shopping cart in PHP - Web Development

Shopping cart in PHP

How to make Shopping cart in Core php

I didn’t have used any PHP framework. This shopping cart in core PHP and it is only for beginners. You will see Add to cart, Add to a product, delete a product, preview product, log in, and log-out. I have written a design code on a different page and business logic code on a different page.


If you run this project in your browser you will see this output. For source code please leave your mail in the comment box.

This is your project structure in your folder. As I said Business logic and design code both have written on different pages.

Now start with a database this is the database design. There are two tables and a total of 9 columns. Save table is used for Registration and Login.

Now I will show you the complete code of connection as know that without connection can’t complete this project.

Save this code as connection.php

Now we will see Sign up page code and login page code. Now see registration.php This page only has designing part and business logic will be on a different page with the name registration_action.php


Now you will see business logic of registration page.


The extract() Function is an inbuilt function in PHP. The extract() function does array to variable conversion.

Now we will see login page but first, we will see design page of login then business logic.

index.php (Design page of Login Form)

Now we will see business logic of Login form index login_action.php

This is our logout page logout.php

error_reporting(0) is used to avoid warning and notice. Now the next step is to add header and footer page. I didn’t add any menu in the header but there is a menu in the footer but the footer menu is empty.



Now we will see the code of home page which showing four data in the front end. You can add more products but I am showing just four product on each row.


Now we will see how to add product in main page . There are total 8 coulumns.

This is designing page of add_product page add_product.php

Now see business logic of add_product page product_action.php

How to see product in diffrent page or on model box . view_detail.php

Now, this is our last code of the project, how to remove a product from the main page. empty_cart.php

If you want source code of this project please drop your mail in the comment box.

2 Replies to “Shopping cart in PHP”

Leave a Reply

Your email address will not be published. Required fields are marked *