November 3, 2016 9:55 am

Create Like & Unlike System in PHP MySQL and jQuery [Improved]

We have created a like and unlike script on our readers request we received many users feedback they face problems in counter etc. Now I have fixed all bugs and created its improved version with multiple like unlike on single page and for products and improve some JavaScript and CSS so I hope you like it.

Create Like & Unlike System in PHP MySQL and jQuery [Improved]

Database Details:
database name => phpgang
table name => products
table name => like
db.sql
Database file run in your MySQL to create database and add data in table.

db.php
Edit this file as per your database credentials.

index.php

Contains PHP code to update table records and show the current number in the file, in this file we used cookie to skip invalid likes and un-likes.

Main file show products list and and like buttons:

To post like button action below code used:

Complete Demo code available in download area click download to download code a running demo here

This is the simple and easy code for like and unlike system I hope you guyz like this please share your feedback in comments. If you face any issue please fee free to comment below.

Author Huzoor Bux

I am Huzoor Bux from Karachi (Pakistan). I have been working as a PHP Developer from last 5+ years, and its my passion to learn new things and implement them as a practice. Basically I am a PHP developer but now days exploring more in HTML5, CSS and jQuery libraries.


Tutorial Categories:
  • David

    Realy like this tutorial and 100% going to implement in my project.

  • Howdy! 🙂 Love it but I am getting an error… “PHP Notice: Undefined variable: HTML in /”
    I think the error is in the “index.php” file. Your demo works great! But I found a typo in the downloaded code:
    See image attached… 🙂 https://uploads.disquscdn.com/images/b24eb0d3ac5e24b7e8d8edfe690be8f10a8f97beee79762011af0bba5b4baad7.jpg

    • Fixed both issues please download a fresh copy of code and use it.

      • Thank you very much 🙂 its 2:40 a.m. here in Arizona I need to get some sleep 🙂 I will try tomorrow. Thank you very much again

  • Nice post!

  • Alexander Fleischer

    In which case the uid would be empty? If i delete my cookies i can vote again and again

    • Php guru

      If you are not logged in then uid will be empty. To vote you need to create account first.

      • Alexander Fleischer

        ok, i thougt it was without an login, like the demo. But in the
        script i’m always logged in. if the session var is not set you set it,
        instead redirecting to a login page