In this first you have to create database and tables, For that you just follow the below given sql query. Here is the two different table one is userprofile table to store the user emails and the second one is otpstore to store the randomly generated otp. First system checks the email is available in the database table. If not it shows the error email not exist. Just store some emails in database table and then try this program, then it will work perfectly and gives the otp to your registered email , After enter the OTP it takes the secure page.
The otp will send using the smtp through the phpmailer so you can provide the host name and email id, password, port number everyting in this mailfunction.php file. to deliver the otp email id. Using this concept you can set this for mobile otp concept. will post the Otp login via mobile in next post. I hope this example is very useful.
Database and Tables:
First create one database name called ‘demo‘
Use the below sql query to create table. and set newid as a primary key while create table
`id` int(11) NOT NULL,
`email` varchar(255) NOT NULL
)
CREATE TABLE `otpstore` (
`otp` varchar(10) NOT NULL,
`is_expired` int(11) NOT NULL,
`create_at` datetime NOT NULL,
`id` int(12) NOT NULL,
`newid` int(12) NOT NULL
) ENGINE=InnoDB DEFAULT CHARSET=latin1;
