Hello, friends in this tutorial we will learn user registration and login using PHP stored procedure.
File structure for this tutorial
config.php
index.php
check_availability.php
login.php
welcome.php
logout.php
Structure of sql table tblregistration
CREATE TABLE `tblregistration` (`id` int(11) NOT NULL, `FullName` varchar(200) NOT NULL, `EmailId` varchar(200) NOT NULL, `Password` varchar(255) NOT NULL, `RegDate` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP) ENGINE=InnoDB DEFAULT CHARSET=latin1;
config.phpCreate db configuration file using mysqli extension. Provide credential as per your configuration
index.php
Create a html form for user registration .
Register Full Name E-mail Password
Jquery / Ajax for user email availability
check_availability.php
In this page we will check the user email availability. Create a store procedure with name check availability
Store procedure code:
DELIMITER $ CREATE DEFINER=`root`@`localhost` PROCEDURE `checkavailbilty`(IN `email` VARCHAR(255)) NO SQL SELECT EmailId FROM tblregistration WHERE EmailId=email$ DELIMITER ;
Now create a store procedure for user registration.
Store procedure for user registration
DELIMITER $ CREATE DEFINER=`root`@`localhost` PROCEDURE `registration`(IN `fname` VARCHAR(200), IN `emailid` VARCHAR(200), IN `password` VARCHAR(255)) NO SQL insert into tblregistration(FullName,EmailId,Password) VALUES(fname,emailid,password)$ DELIMITER ;
After creation of store procedure execute the store procedure.
Here is the full code that we have written for registration (index.php ):
Registration using Store Procedure function checkAvailability() { $("#loaderIcon").show(); jQuery.ajax({ url: "check_availability.php", data:"emailid="+$("#email").val(), type: "POST", success:function(data){ $("#user-availability-status").html(data); $("#loaderIcon").hide(); }, error:function (){} }); } Register Full Name E-mail Password
login .phpCreate a login form user login.
login
Now create a store procedure for login with name login.
Login store procedure:
DELIMITER $ CREATE DEFINER=`root`@`localhost` PROCEDURE `login`(IN `useremail` VARCHAR(255), IN `password` VARCHAR(255)) NO SQL SELECT EmailId,Password from tblregistration where EmailId=useremail and Password=password$ DELIMITER ;
Now execute the login store procedure
Значение слова неудачный
Обзор Samsung Galaxy A7 (2017): не боится воды и экономии Стоит ли покупать samsung a7
Делаем бэкап прошивки на андроиде
Как настроить файл подкачки?
Установка режима совместимости в Windows