create-simple-rest-api-in-php
Home PHP

How To Create A Simple REST API in PHP? Step By Step Guide!


Previously, we learned how to create, read, update and delete database records (CRUD operations) with our PHP, MySQL & OOP CRUD Tutorial.

Today, before we go to JavaScript programming, we will learn how to create a simple REST API in PHP. Enjoy our step-by-step tutorial below!

This post covers the following topics:

Read more

Home PHP

Simple PHP Tournament Script – PHP & AngularJS – Download Source Code

simple-php-tournament-script-angularjs
Important Note: This script is not updated in a while. But it still works. Download at your own risk.

Download and learn how this simple tournament script was made. Technologies used include PHP, MySQL, AngularJS, Material Design and jQuery.

Contents of this page include:

Read more

simple-php-contact-form-script
Home PHP

PHP Contact Form Script – Messages Module – Download Now!

simple-php-contact-form-script

Download and learn how this simple PHP Contact Form Script was made. Technologies used include PHP OOP, MySQL, Bootstrap and HTML5.

Contents of this page include:

Read more

php-web-page-content-management-system
Home PHP

PHP Web Page Content Management System – Download Now!

php-web-page-content-management-system
Looking for PHP Contact Form Script? Click Here.

Download and learn how this simple PHP Web Page Content Management System was made. Technologies used include PHP OOP, MySQL, Bootstrap and jQuery.

Contents of this page include:

Read more

php-product-catalog-script
Home PHP

PHP Product & Category Management Module – PHP Product Catalog Script

php-product-catalog-script

Note

Before You Download, make sure you have basic understanding of these topics:

a. PHP Object Oriented CRUD Example with Bootstrap

b. Apache .htaccess RewriteRule Examples with PHP

Demo Link

Experience the live demo by sending a request to mike@codeofaninja.com, your email subject must be “DEMO Request: PHP Product Catalog Script”.

Features List

FEATURE ACCESS LEVEL Source Code
USER MANAGEMENT
User type: Admin Admin Yes
Interface for admin Admin Yes
Login page Admin Yes
Log out Admin Yes
PRODUCT MANAGEMENT
Create product Admin Yes
Read products Admin Yes
Update product Admin Yes
Delete product Admin Yes
Search product Admin & Customer Yes
Product lists with pagination Admin & Customer Yes
View inactive products Admin Yes
View products under a category Admin & Customer Yes
Product list under a category with pagination Admin & Customer Yes
Upload product images, you can select many images at once Admin Yes
View product images with thumbnails Admin & Customer Yes
Delete product image with X icon Admin Yes
Upload product PDFs , you can select many PDF files at once Admin Yes
List product PDF Admin Yes
Delete product PDF Admin Yes
View single product with related information Customer Yes
View single product with add to cart button Customer Yes
View single product with image slider Customer Yes
View single product with SEO friendly URL (.htaccess file used) Customer Yes
Rich text editor for product description when adding or editing product Admin Yes
Quantity value must be more than 1 Customer Yes
Sorting by fields Admin Yes
CATEGORY MANAGEMENT
Create category Admin Yes
Read categories Admin Yes
Update category Admin Yes
Delete category Admin Yes
Search category Admin Yes
Category list with pagination Admin Yes
Category search result with pagination Admin Yes
View products under a product category Admin & Customer Yes
Auto update category drop down in create or update product form Admin Yes
Auto update categories in navigation bar Admin & Customer Yes
Highlight selected category in navigation Admin & Customer Yes
SECURITY
Login user with hashed password validation Customer & Admin Yes
Used PDO bindParam() to prevent SQL injection in all MySQL queries Developer Yes
Used PHP htmlspecialchars() and strip_tags() to prevent XSS attacks Developer Yes
MORE REASONS TO DOWNLOAD IT
Object oriented programming source code Developer Yes
Bootstrap user interface Developer Yes
PDO extension used Developer Yes
Page title navigation with links Developer Yes
Radio button looks like a switch Developer Yes
Icon in all create, edit and delete buttons Developer Yes
All source code files organized by folders Developer Yes
Database configuration file in config folder Developer Yes
SQL file and READ-ME.txt in “sql” folder Developer Yes
SQL file and READ-ME.txt in “dev” folder Developer Yes
Database design and data dictionary in “dev” folder Developer Yes
Free source code updates / new features update Developer Yes
Free support for 6 months Developer Yes
Buy once, use for unlimited number of sites Developer Yes
One-time payment, no recurring payment Developer Yes

THANK YOU!

has been added to your cart!

Powered by Easy Digital Downloads

Thank you!

have been added to your cart!

Powered by Easy Digital Downloads

Simple Configuration

Source code simple configuration when you install:

1. This system works with PHP 5.4+

2. In your PhpMyAdmin, create a database “php_product_catalog”

3. Import the SQL file php_product_catalog.sql in the “dev” folder

4. Rewrite module must be enable in your apache server

5. Change rewrite base directory in line 7 of .htaccess file

6. Configure $home_url in /config/core.php

7. Configure database in /config/database.php

8. User Login
Admin Section Login
Username: mike@example.com
Password: ninja12qw!@QW

Thanks For Your Help!

Contact me if you have any questions about the code, I’ll be more than happy to help and support you!

My email is mike@codeofaninja.com, you can also contact me via our official Facebook page.

Thank you visiting our for PHP Product Catalog Script page!

php-online-shopping-cart-source-code
Home PHP

PHP Shopping Cart & Ordering Module – Source Code – Download Now!

php-online-shopping-cart-source-code
Contents of this post include:

1.0 Output Preview & Demo Link
2.0 Pre-Requisites
3.0 Cart Data Storage
4.0 File Structure
5.0 What People Say?
6.0 Features List & Download
7.0 Simple Set Up
8.0 Need More Features?
9.0 Related Source Codes
10.0 Get In Touch

1.0 Output Preview & Demo Link

The following slideshow is the output preview of this source code.

Customer Section Output Preview:


Admin Section Output Preview:


If you need the live demo link, send a request to mike@codeofaninja.com with subject “PHP Shopping Cart Module”, thank you!

Note: The “PHP Shopping Cart Module” is also called the “LEVEL 3 source code” of our PHP Shopping Cart Tutorials – PHP SESSIONS, PHP COOKIES and MySQL.

2.0 Pre-Requisites

Before you download, make sure you have basic understanding of these topics:

a. PHP Object Oriented CRUD Example with Bootstrap
b. Apache .htaccess RewriteRule Examples with PHP

3.0 Cart Data Storage

This source code takes advantage of PHP SESSIONS, PHP COOKIES and MySQL when storing cart data.

  • We use PHP COOKIES to save site visitor’s user_id locally.
  • We use PHP SESSIONS as back up just in case cookies are disabled in user’s browser.
  • We use MySQL to store cart items in the database.
  • This way, cart items can be resurrected even if user closed his browser, logged out or logged in another computer.

Here’s the logic:

IF cookies are enabled, AND if user is logged in, we save ‘session user_id’ to ‘user_id variable’. The value of ‘user_id variable’ is very important because we use it to save ‘user_id’ both in PHP ‘cookie’ and ‘session’.

IF cookies are enabled, AND if user is not logged in, AND if user already have a ‘cookie user_id’ token, we save ‘cookie user_id’ to ‘user_id variable’.

IF cookies are enabled, AND if user is not logged in, AND if ‘cookie user_id’ is not set (it means, visitor never used the cart before), we get new token as ‘user_id variable’ value.

IF cookies are enabled, AND user is logged in OR not logged in, we set ‘cookie user_id’ and ‘session user_id’ with the final ‘user_id variable’ value. This will retrieve the cart data with the same ‘user_id’ from MySQL database.

IF cookies are disabled, AND user is logged in, we maintain ‘session user_id’.

IF cookies are disabled, AND user is not logged in, we get new token and save it to ‘session user_id’.

Important Note: The statements above can be understood more clearly if you will see the code implementation on /config/core.php line 26 onwards.

4.0 File Structure

The following folders and files are included in our source code. It will have more meaning if you will see the code inside the folders and files.
├─ admin/
├─── category.php
├─── change_order_status.php
├─── create_product.php
├─── create_user.php
├─── create_image.php
├─── delete_pdf.php
├─── delete_product.php
├─── delete_user.php
├─── layout_foot.php
├─── layout_head.php
├─── login_checker.php
├─── navigation.php
├─── order_history.php
├─── paging.php
├─── read_inactive_products.php
├─── read_one_order.php
├─── read_orders_template.php
├─── read_orders.php
├─── read_products_sorted_by_fields.php
├─── read_products_template.php
├─── read_products.php
├─── read_users_template.php
├─── read_users.php
├─── search_orders.php
├─── search_products.php
├─── search_users.php
├─── update_product.php
├─── update_user.php
├─ config/
├─── core.php
├─── database.php
├─ dev/
├─── shop_cart_ordering_module.sql
├─── readme.txt
├─ images/
├─ libs/
├─── css/
├────── bootstrap/
├────── admin.css
├────── user.css
├─── js/
├────── bootstrap-image-gallery/
├────── jquery-ui/
├────── yellow-text/
├────── bootbox.min.js
├────── custom-script.js
├────── jquery.js
├─── php/
├────── php-mailer/
├────── pw-hashing/
├────── utils.php
├─ objects/
├─── cart_item.php
├─── category.php
├─── order_item.php
├─── order.php
├─── product_image.php
├─── product_pdf.php
├─── product.php
├─── user.php
├─ uploads/
├─── images/
├─── pdfs/
├─ .htaccess
├─ add_to_cart.php
├─ cart.php
├─ category.php
├─ checkout.php
├─ empty_cart.php
├─ info.php
├─ layout_foot.php
├─ layout_head.php
├─ login_checker.php
├─ login.php
├─ logout.php
├─ navigation.php
├─ orders.php
├─ paging.php
├─ place_order.php
├─ product.php
├─ products.php
├─ read_one_order.php
├─ remove_from_cart.php
├─ search.php
├─ update_quantity.php

5.0 What People Say?

Here’s what people feel about our work and source code downloads.

6.0 Features List & Download

FEATURE ACCESS LEVEL SOURCE CODE
USER MANAGEMENT
Create user Admin YES
Read users Admin YES
Update user Admin YES
Delete user Admin YES
Search user Admin YES
Users list pagination Admin YES
Valid email format required Admin & Customer YES
Password must be uppercase letter, lowercase letter, number and special character Admin & Customer YES
Confirm password field Admin YES
Password validation as you type Admin YES
View customer order history Admin & Customer YES
Deleting first administrator account is not allowed Admin YES
User types: Admin and Customer Admin & Customer YES
Interface for admin Admin YES
Interface for customer Customer YES
Login page Admin & Customer YES
Log out Admin & Customer YES
Edit profile of currently logged in user Admin YES
Show name with icon of currently logged in user Admin & Customer YES
PRODUCT MANAGEMENT
Create product Admin YES
Read products Admin YES
Update product Admin YES
Delete product Admin YES
Search product Admin & Customer YES
Product lists with pagination Admin & Customer YES
View inactive products Admin YES
View products under a category Admin & Customer YES
Product list under a category with pagination Admin & Customer YES
Upload product images, you can select many images at once Admin YES
View product images with thumbnails Admin & Customer YES
Delete product image with X icon Admin YES
Upload product PDFs , you can select many PDF files at once Admin YES
List product PDF Admin YES
Delete product PDF Admin YES
View single product with related information Customer YES
View single product with add to cart button Customer YES
View single product with image slider Customer YES
View single product with SEO friendly URL (.htaccess file used) Customer YES
Rich text editor for product description when adding or editing product Admin YES
Quantity value must be more than 1 Customer YES
Sorting by fields Admin YES
View products under a product category Admin & Customer YES
Highlight selected category in navigation Admin & Customer YES
ORDER MANAGEMENT
Make an order Customer YES
Auto-generated unique transaction ID Customer YES
Add to cart button (for each item) with specified quantity Customer YES
Cart page with list of products added to cart Customer YES
Update quantity button for each item in cart page Customer YES
Auto-compute subtotal in cart page Customer YES
Auto-compute grand total in cart page Customer YES
Remove from cart button for each item in the cart Customer YES
Empty cart button to remove all items in the cart Customer YES
View order history of a customer Admin & Customer YES
View pending and completed order in separate tabs Admin YES
Checkout page Customer YES
Show billing information on check-out page Customer YES
Show payment information on checkout page Customer YES
Payment via cash on delivery Customer YES
Place order page – Thank you message Customer YES
View list of orders Customer YES
Pagination on list of orders Admin & Customer YES
Latest order seen at the top of the list Admin & Customer YES
View details of an order Admin & Customer YES
Auto-compute order totals Admin & Customer YES
Change status of an order (pending or completed) Admin YES
SECURITY
Register user hashed password stored in the database Customer YES
Edit user profile hashed password update in the database Admin YES
Create user hashed password stored in the database Admin YES
Login user with hashed password validation Customer & Admin YES
Used PDO bindParam() to prevent SQL injection in all MySQL queries Developer YES
Used PHP htmlspecialchars() & strip_tags() to prevent XSS attacks Developer YES
MORE REASONS TO DOWNLOAD IT
Object oriented programming source code Developer YES
Bootstrap user interface Developer YES
PDO extension used Developer YES
Page title navigation with links Developer YES
Radio button looks like a switch Developer YES
Icon in all create, edit and delete buttons Developer YES
All source code files organized by folders Developer YES
Database configuration file in config folder Developer YES
SQL file and READ-ME.txt in “dev” folder Developer YES
Database design and data dictionary in “dev” folder Developer YES
Well explained / commented source code Developer YES
Free support for 6 months Developer YES
Free source code updates. Developer YES
Buy once, use for unlimited number of sites Developer YES
One-time payment, no recurring payment Developer YES

THANK YOU!

has been added to your cart!

Powered by Easy Digital Downloads

Thank you!

have been added to your cart!

Powered by Easy Digital Downloads

7.0 Simple Set Up

Source code simple set up when you install:

1. Extract the ZIP file to your server directory.

2. In your PhpMyAdmin, create a database “shop_cart_module”

3. Import the “shop_cart_module.sql” SQL file in the “dev” folder

4. Change rewrite base directory in line 7 of .htaccess file (if needed)

5. Change $home_url in /config/core.php (if needed)

6. Configure database in /config/database.php

7. Run product.php – this is the main file, not index.php

8. User Login
Admin Section Login
Username: mike@example.com
Password: ninja12qw!@QW

Customer Account Login
Username: darwin@example.com
Password: darwin12qw!@QW

How To Make TinyMCE File Manager / File Browser Work?

1. Change line 71 of /libs/js/responsive_filemanager/filemanager/config/config.php

'upload_dir' => '/YOUR_ROOT_DIRECTORY/libs/js/responsive_filemanager/source/',

2. Change line 42-43 of /admin/layout_foot.php

external_filemanager_path:"/YOUR_ROOT_DIRECTORY/libs/js/responsive_filemanager/filemanager/",
external_plugins: { "filemanager" : "/YOUR_ROOT_DIRECTORY/libs/js/responsive_filemanager/filemanager/plugin.min.js"},

I’ll keep you updated via email with the update information and download link. Download the source code by clicking the green button below. Once your payment was sent, you’ll receive the download link on your email.

THANK YOU!

has been added to your cart!

Powered by Easy Digital Downloads

Thank you!

have been added to your cart!

Powered by Easy Digital Downloads

8.0 Need More Features?

If you think you now need more features, you can try our “PHP Shopping Cart System” – it has highly related and useful features for your PHP shopping cart project.

Below are some screenshots of the system’s output. You can click an image to view the larger version of it. Use the left and right arrow to navigate through the screenshots.

Please note that the following images are just output previews. New features might be added already the time you are reading this.

Output preview when customer is not logged in.


Output preview when customer is logged in.


Output preview when admin / merchant is logged in.


To learn more and to download our PHP Shopping Cart System, Click Here.

10.0 Get In Touch

Contact me if you have any questions about the code, I’ll be more than happy to help and support you!

My email is mike@codeofaninja.com, you can also contact me via our official Facebook page.

Please subscribe as well to receive news and updates about our source codes and free tutorials. Fill out the form below.

  • 1. You learned a lot from our valuable web programming tutorials.
  • 2. You will learn more because we constantly update each tutorial.
  • 3. You will get FREE email updates once a week, if you subscribe.
100% Privacy. We will never spam you!

Thank you visiting our for PHP Online Shopping Cart Source code download page!

php-login-system
Home PHP

PHP Login System & User Management Module

php-login-system

This source code is about PHP Login System. It will help you understand how to login and logout functionality works. Sign up email verification, user registration, and forgot password features are included as well.

The basic idea is, we will have two user access levels: the ‘Admin’ and ‘Customer’.

If the ‘Customer’ is logged in, he can access pages assigned for him to be accessed, like the edit profile and index page for ‘Customer’.

If the ‘Admin’ is logged in, he can create, read list, update, delete and search users. See the full list of features in the table below.

Where’s the tutorial? We call this a tutorial because if your download the source code, you can ask me anything related to it. I can personally teach you the code and other tips you need.

That’s how we go about it for now. Formal tutorial or documentation of this code is coming soon. I’m currently working on it. Thanks for understanding!

Source Code LIVE DEMO

If you need the live demo link, send a request to mike@codeofaninja.com with subject “Login System Demo Link Request”, thank you!

PHP Login System Features

You can see the features and download it below.

Feature Login System
Login form with email and password YES
PHP Sessions are used to identify logged in and logged out users. YES
Hashed password stored in database YES
Register form YES
Password and confirm password fields YES
Check if password matches YES
Sending of verification link to email YES
Validation page of email link YES
Check if password is strong enough YES
Email sending works with remote host only. YES
Redirection to login page if not yet logged in YES
Forgot password page YES
Password reset link sent to email YES
Password reset page YES
Customer access to index page when logged in YES
Customer access to edit profile page when logged in YES
Customer change password page YES
Customer password and confirm password field when editing profile YES
Customer logout YES
Admin create user YES
Admin read users YES
Admin update user YES
Admin delete user YES
Admin change of user access level: Admin or Customer YES
Admin search user by email address YES
Admin users list paging YES
Admin edit profile YES
Admin logout YES
Admin change password page YES
Admin can change user passwords YES
Admin can manually change status of users (pending or approved) YES
Require login in admin index page, edit profile page and users CRUD pages. YES
Bootstrap enabled user interface YES
Free support for 6 months. YES
Free source code updates. YES

THANK YOU!

has been added to your cart!

Powered by Easy Digital Downloads

Thank you!

have been added to your cart!

Powered by Easy Digital Downloads

Some Notes

#1 Found An Issue?

If you found a problem with this code, we can solve it faster via Email or FB message, please send me a message via email mike@codeofaninja.com, or via our official Facebook page!

Please be more detailed about your issue. Best if you can provide an error message and your test or page URL. Thanks!

Please feel free to comment if you have any questions, suggestions, found something wrong or want to contribute to this code.

#2 Become a true Ninja!

We constantly add new tutorials and improve our existing tutorials and source codes. Be one of the first to know an update by subscribing to our FREE newsletter. Get a FREE EBOOK as well. CLICK HERE TO SUBSCRIBE FOR FREE!

#3 Thank You!

Thanks for reading our PHP Login System Tutorial with Admin Features.

paypal-integration-in-php
Home PHP

PayPal Integration In PHP – Source Code Download!

paypal-integration-in-php

This code will solve your problem and answer your question: how to add PayPal and credit card on checkout?

You can use this code on your PHP shopping cart script. This is an add-on to our shopping cart scripts like this as well.

PayPal Integration In PHP – Output Preview

You can watch the demo video below to see how the source code works.

Live Demo

If you still need a live demo after watching our demo video above, send and email request to mike@codeofaninja.com with a subject “DEMO: PayPal Integration in PHP”.

Live demo is in sandbox (testing) mode, so please use your PayPal sandbox account. You can create a PayPal sandbox account using this PayPal developer link.

How To Set Up / Enable Auto Return?

With Auto Return for PayPal Website Payments, your buyers are redirected back to your site immediately after clicking the Pay button on the Payment Confirmation page.

Your buyers enjoy a streamlined checkout experience and are returned back to your site quickly!

Enable Auto Return In Your Test / Sandbox Account.

  1. Log into https://developer.paypal.com
  2. Click Applications
  3. Click Sandbox accounts
  4. Expand the account in question
  5. Click Sandbox site
  6. Login to the test account
  7. Copy and paste “https://www.sandbox.paypal.com/us/cgi-bin/webscr?cmd=_profile-website-payments” into your browser
  8. Enable Auto Return and click Save
  9. Enter the Auto Return URL and click Save

[Reference]

Setting Up Auto Return On Your Official / Real PayPal Account

  1. Log in and click the Profile subtab under My Account.
  2. Click the Website Payment Preferences link under Selling Preferences.
  3. Click the On radio button to enable Auto Return.
  4. Enter the Return URL. Note: You must meet the Return URL requirements in order to set up Auto Return. Learn more about Return URL.

[Reference]

Download Source Code

It is more convenient if you can just download the complete source code we used and play around with it. There’s a small fee in getting the complete source code, it is small compared to the:

✔ Value or skill upgrade it can bring you, or YES
✔ Income you can get from your website project or business. YES
✔ Precious time you save. YES
✔ Expert advice you can get from us, just in case you have any questions related to the source code. YES

For a limited time, I will give you the source code for a low price. DOWNLOAD THE SOURCE CODE you desire by clicking its the BUY button below.

You can see the features list and download it below.

Feature Add On
Pay with PayPal YES
Pay with credit card (via PayPal) YES
Pay with debit card (via PayPal) YES
Set merchant email address / PayPal ID YES
Set currency and currency symbol YES
Set return URL (your site URL when user was done with the payment) YES
Set cancel URL (your site URL when user cancels order) YES
Support automatic redirect to your site YES
Free support for 6 months YES
Free source code updates. YES

THANK YOU!

has been added to your cart!

Powered by Easy Digital Downloads

Thank you!

have been added to your cart!

Powered by Easy Digital Downloads

THANK YOU!

Thanks for viewing our source code about PayPal Integration In PHP!

If you have any questions, comments or suggestions, please do not hesitate to contact me.
a. Send me an email. My email address is mike@codeofaninja.com
b. Go to https://fb.com/codeofaninja and chat me up.