Skip to content

adhir2099/php-ajax-sweetalert2-login

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PHP Responsive Bootstrap Ajax

PHP ajax sweetalert2 Log in

Log in with ajax and sweetAlert2, no jquery needed. For alerts we're using SweetAlert 2.

Backend

Frontend

Database

    CREATE DATABASE login;

    USE `login`;

    DROP TABLE IF EXISTS `users`;

    CREATE TABLE `users` (
    `id` int(11) NOT NULL AUTO_INCREMENT,
    `email` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    `pass` varchar(64) COLLATE utf8mb4_unicode_ci DEFAULT NULL,
    PRIMARY KEY (`id`)
    ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

    insert  into `users`(`id`,`email`,`pass`) values 
    (1,'demoz@demologin.com','@demologin');

Config parameter

In loginController.php , you may changed the if statement for password_verify(), remember, function requires the first argument to be a plain text password + hashed password from DB. In this example we don't use hashed passwords and uses a simple DB for practice purposes.

    password_verify($_POST["pass"], $hashed_password_from_database)

Libraries included

  • Bootstrap v5.3
  • FontAwesome 5.15
  • Sweetalert2

Contributing

  1. Fork it!
  2. Create your feature branch: git checkout -b your-branch
  3. Commit your changes: git commit -am 'Add some feature'
  4. Push to the branch: git push origin your-branch
  5. Submit a PR

Get in touch with me:

adhir2099

Created with ❤️ by Adhir2099