Создание простой системы регистрации пользователей на PHP и MySQL. Создаем невероятную простую систему регистрации на PHP и MySQL Вымышленный reg user php

Trackbacks (0)

Updated on: 2019-10-08

Posted on: 2016-12-21

Over time PHP has been adding features that promote the development of secure applications, as well deprecated or removed features that made it easy to write insecure code.

Read this tutorial to learn how to create a modern login and registration system that takes advantage of PHP security-focused features and uses jQuery to send AJAX requests and Bootstrap to provide a fast and nice user interface that can work regardless if you use other frameworks or not.



If you have questions or comments you can post a message as comment to this article or in its .

Change Log

2017-03-27: Added more download and install information using the composer tool.

2017-01-01: Updated the article to reflect that these continue to be secure practices in 2017




You need to be a registered user or login to post a comment Login Immediately with your account on:

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.php

Create 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

Already registered. login here

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

Already registered. login here

login .php

Create a login form user login.

login

Not registered? Create an account

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