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

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

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

FEATUREACCESS LEVELSource Code
USER MANAGEMENT
User type: AdminAdminYes
Interface for adminAdminYes
Login pageAdminYes
Log outAdminYes
PRODUCT MANAGEMENT
Create productAdminYes
Read productsAdminYes
Update productAdminYes
Delete productAdminYes
Search productAdmin & CustomerYes
Product lists with paginationAdmin & CustomerYes
View inactive productsAdminYes
View products under a categoryAdmin & CustomerYes
Product list under a category with paginationAdmin & CustomerYes
Upload product images, you can select many images at onceAdminYes
View product images with thumbnailsAdmin & CustomerYes
Delete product image with X iconAdminYes
Upload product PDFs , you can select many PDF files at onceAdminYes
List product PDFAdminYes
Delete product PDFAdminYes
View single product with related informationCustomerYes
View single product with add to cart buttonCustomerYes
View single product with image sliderCustomerYes
View single product with SEO friendly URL (.htaccess file used)CustomerYes
Rich text editor for product description when adding or editing productAdminYes
Quantity value must be more than 1CustomerYes
Sorting by fieldsAdminYes
CATEGORY MANAGEMENT
Create categoryAdminYes
Read categoriesAdminYes
Update categoryAdminYes
Delete categoryAdminYes
Search categoryAdminYes
Category list with paginationAdminYes
Category search result with paginationAdminYes
View products under a product categoryAdmin & CustomerYes
Auto update category drop down in create or update product formAdminYes
Auto update categories in navigation barAdmin & CustomerYes
Highlight selected category in navigationAdmin & CustomerYes
SECURITY
Login user with hashed password validationCustomer & AdminYes
Used PDO bindParam() to prevent SQL injection in all MySQL queriesDeveloperYes
Used PHP htmlspecialchars() and strip_tags() to prevent XSS attacksDeveloperYes
MORE REASONS TO DOWNLOAD IT
Object oriented programming source codeDeveloperYes
Bootstrap user interfaceDeveloperYes
PDO extension usedDeveloperYes
Page title navigation with linksDeveloperYes
Radio button looks like a switchDeveloperYes
Icon in all create, edit and delete buttonsDeveloperYes
All source code files organized by foldersDeveloperYes
Database configuration file in config folderDeveloperYes
SQL file and READ-ME.txt in “sql” folderDeveloperYes
SQL file and READ-ME.txt in “dev” folderDeveloperYes
Database design and data dictionary in “dev” folderDeveloperYes
Free source code updates / new features updateDeveloperYes
Free support for 6 monthsDeveloperYes
Buy once, use for unlimited number of sitesDeveloperYes
One-time payment, no recurring paymentDeveloperYes

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 are some of the things people say about our source code downloads.

6.0 Features List & Download

FEATUREACCESS LEVELSOURCE CODE
USER MANAGEMENT
Create userAdminYES
Read usersAdminYES
Update userAdminYES
Delete userAdminYES
Search userAdminYES
Users list paginationAdminYES
Valid email format requiredAdmin & CustomerYES
Password must be uppercase letter, lowercase letter, number and special characterAdmin & CustomerYES
Confirm password fieldAdminYES
Password validation as you typeAdminYES
View customer order historyAdmin & CustomerYES
Deleting first administrator account is not allowedAdminYES
User types: Admin and CustomerAdmin & CustomerYES
Interface for adminAdminYES
Interface for customerCustomerYES
Login pageAdmin & CustomerYES
Log outAdmin & CustomerYES
Edit profile of currently logged in userAdminYES
Show name with icon of currently logged in userAdmin & CustomerYES
PRODUCT MANAGEMENT
Create productAdminYES
Read productsAdminYES
Update productAdminYES
Delete productAdminYES
Search productAdmin & CustomerYES
Product lists with paginationAdmin & CustomerYES
View inactive productsAdminYES
View products under a categoryAdmin & CustomerYES
Product list under a category with paginationAdmin & CustomerYES
Upload product images, you can select many images at onceAdminYES
View product images with thumbnailsAdmin & CustomerYES
Delete product image with X iconAdminYES
Upload product PDFs , you can select many PDF files at onceAdminYES
List product PDFAdminYES
Delete product PDFAdminYES
View single product with related informationCustomerYES
View single product with add to cart buttonCustomerYES
View single product with image sliderCustomerYES
View single product with SEO friendly URL (.htaccess file used)CustomerYES
Rich text editor for product description when adding or editing productAdminYES
Quantity value must be more than 1CustomerYES
Sorting by fieldsAdminYES
View products under a product categoryAdmin & CustomerYES
Highlight selected category in navigationAdmin & CustomerYES
ORDER MANAGEMENT
Make an orderCustomerYES
Auto-generated unique transaction IDCustomerYES
Add to cart button (for each item) with specified quantityCustomerYES
Cart page with list of products added to cartCustomerYES
Update quantity button for each item in cart pageCustomerYES
Auto-compute subtotal in cart pageCustomerYES
Auto-compute grand total in cart pageCustomerYES
Remove from cart button for each item in the cartCustomerYES
Empty cart button to remove all items in the cartCustomerYES
View order history of a customerAdmin & CustomerYES
View pending and completed order in separate tabsAdminYES
Checkout pageCustomerYES
Show billing information on check-out pageCustomerYES
Show payment information on checkout pageCustomerYES
Payment via cash on deliveryCustomerYES
Place order page – Thank you messageCustomerYES
View list of ordersCustomerYES
Pagination on list of ordersAdmin & CustomerYES
Latest order seen at the top of the listAdmin & CustomerYES
View details of an orderAdmin & CustomerYES
Auto-compute order totalsAdmin & CustomerYES
Change status of an order (pending or completed)AdminYES
SECURITY
Register user hashed password stored in the databaseCustomerYES
Edit user profile hashed password update in the databaseAdminYES
Create user hashed password stored in the databaseAdminYES
Login user with hashed password validationCustomer & AdminYES
Used PDO bindParam() to prevent SQL injection in all MySQL queriesDeveloperYES
Used PHP htmlspecialchars() & strip_tags() to prevent XSS attacksDeveloperYES
MORE REASONS TO DOWNLOAD IT
Object oriented programming source codeDeveloperYES
Bootstrap user interfaceDeveloperYES
PDO extension usedDeveloperYES
Page title navigation with linksDeveloperYES
Radio button looks like a switchDeveloperYES
Icon in all create, edit and delete buttonsDeveloperYES
All source code files organized by foldersDeveloperYES
Database configuration file in config folderDeveloperYES
SQL file and READ-ME.txt in “dev” folderDeveloperYES
Database design and data dictionary in “dev” folderDeveloperYES
Well explained / commented source codeDeveloperYES
Free source code updates / new features updatesDeveloperYES
Free support for 6 monthsDeveloperYES
Buy once, use for unlimited number of sitesDeveloperYES
One-time payment, no recurring paymentDeveloperYES

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.

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. We are currently building more high quality tutorials about Vue.js, PHP, Laravel, CakePHP, and Social Media APIs.
  • 2. If you want any of these skills in your resume, please subscribe using the form below. IT'S FREE!
100% Privacy. We will never spam you!

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

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.

FeatureLogin System
Login form with email and passwordYES
PHP Sessions are used to identify logged in and logged out users.YES
Hashed password stored in databaseYES
Register formYES
Password and confirm password fieldsYES
Check if password matchesYES
Sending of verification link to emailYES
Validation page of email linkYES
Check if password is strong enoughYES
Email sending works with remote host only.YES
Redirection to login page if not yet logged inYES
Forgot password pageYES
Password reset link sent to emailYES
Password reset pageYES
Customer access to index page when logged inYES
Customer access to edit profile page when logged inYES
Customer change password pageYES
Customer password and confirm password field when editing profileYES
Customer logoutYES
Admin create userYES
Admin read usersYES
Admin update userYES
Admin delete userYES
Admin change of user access level: Admin or CustomerYES
Admin search user by email addressYES
Admin users list pagingYES
Admin edit profileYES
Admin logoutYES
Admin change password pageYES
Admin can change user passwordsYES
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 interfaceYES
Free source code updates and support for 6 months.YES

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.

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, orYES
✔ 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.

FeatureAdd On
Pay with PayPalYES
Pay with credit card (via PayPal)YES
Pay with debit card (via PayPal)YES
Set merchant email address / PayPal IDYES
Set currency and currency symbolYES
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 siteYES
Free support for 6 monthsYES

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.