Email Verification - Part 2/5: Registration with Email Verification SMTP using Link in PHP MySQL

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
hey guys welcome back so guys in this video we are learning about how to make a registration form with email verification so once we register the time the data should get saved in our database and one email verification should be sent so once you verify the email that time you will be able to login it okay so if you want to know how this form is designed please watch out the previous video which is the part one of this email verification so this is a part two and now guys let's get started with it so first let us move to register.php file go over here register.php and this is a simple form over here now let's type the code is equal to which will be the post method and we will go to page called code.php so let's create a file named code.php and inside this we need to start the code so let's type php open and php close and inside this when you click on register now button that time you are going to check with the name first so register underscore button let's copy this button name and go to code.php with the post method by taking all its input fields okay so let's move how can you check that if the button is clicked or not so we will use a set function with the help of post method we will check that button is set or not okay so if it is clicked it will be in come inside this if condition so now guys what are the fields we required to take that so let's call this names input fields so let's type dollar name which is the variable and dollar underscore post off the name okay so same way you're going to type so let me just divide this page over here so this is the phone paste and then this is the email copy email and then password so let's copy this and save so let's close again and open this code.php file done guys so this is how we are going to add with these four fields so now let's check that email exist or not first step so let's type email exists or not so that query we are going to type so check email query we are going to tell over here and let's type the query select star you can tell all things are just email field so in my table that is users where i have created one column called email so i'm going to select only this email column where from user table so my table name over here you can see user so let's copy that user table where condition email is equal to dollar email okay so inside single quotes we have to give this email with the limit which i'm going to give one okay and now guys over here you need to execute this query so let's tell query run is equal to with the help of mysqli underscore query function where you are going to give first database connection and then your above statement or query so let's type that and now guys you can check with the if else condition it is success or not so before checking this condition you need to create a database connection so let's create one dbcon.php file db con dot php file and now over here let's type the connection dollar co n is equal to my sqli underscore connect function where first will be localhost the second name which is root password is null and then database name which is php tutorials i have created so let's save and now let's call this file dbcon in code.php with the help of include function let's type dbcon dot php file done so now let's check this again so if the condition is successful if it is there so what is there email id exist or not so we are going to check with the mysqlite number of rows okay number of rows in this query exist it is greater than 0 then please come in that it should tell user already exist so let's create one session variable session which will be status and over here we are going to show that email id already exist exists exists and after that header location back to the same page register.php register.php and now if you are using session make sure you have starting the session at the top of the page so guys now let us move to else condition if there is a record then you have to insert the registered user so insert user or registered users data so let's type that query so dollar query is equal to where you are going to tell insert into table name so my table name is users with the column where values values function function where inside this you are going to pass all these variables according to your requirements in your table so let's go to user table and see how many fields so here total i have created six which is name phone email password verify token and created at so let's type this all fields so let's go to browse and over here let me just copy this so created we don't require because it's a timestamp let's move and paste inside this done so let me just separate with the comma and over here these fields again okay so let's copy this dollar name and insert over here inside single quotes and give comma again single quotes dollar phony phone you can give comma single quotes where dollar email comma single quotes were dollar password so let me just close this sidebar and then final one which will be dollar verify token so let's copy this variable and create a random number and alphabet so let's use md5 function where inside that random numbers so this will generate integer and alphabetic numbers which will be messed up okay and we are going to store into this table so guys now let's execute this above query so we'll tell query underscore run is equal to with the help of mysqli query function we are going to execute the above statement so first database connection and then your query so let's copy this query and paste over here simple so guys now if it is success then you it should show so we will satisfy this with the if condition if this query is successful then it will come inside this and send the message if it is not then it will go in else condition and then same way we are going to print this message so let's copy this and again let's still over here registration failed and back to register.php and if it is success then we are going to here registration success full please verify your email address okay so guys now to verify email address we need to send the mail so let's create one send email verification verif verify okay we are going to create one function so inside this function you are going to some send some details so let's pass that over here so fill password dollar name and then dollar email address and then your verification token so let's copy this and paste so let's create this one function of this let's move at the top and i'm going to create a simple function where inside this the function details so what are the fields we are going to pass nothing but this same fields so let's copy this and paste again and remove the double quotes from it just remove that that's it and now guys let's type the code to send the mail so for that let's add the php mailer so let's move to this function and go to google chrome let's search php mailer let's go with the github php mailer and now let's move down over here so installation and loading so let's install this using composer so let's copy this get back on your terminal new terminal and paste that ctrl v hit enter to install make sure your composer is installed then only you can proceed with it okay cool so finally our php mailer is installed and now let me just close with this so guys you can find that one vendor folder and two composer file which is one is jsn and one is lock so guys now let's get back to github of php mailer and over here you can see let's use this copy so i require only few things so i'm going to copy that things only i'm not going to copy full let's paste not inside the function we will paste outside the function take that and inside this you are going to copy so let's take this php my layer and let me just paste what are the things i require from it okay so let's get back let me paste done so guys over here you can see few things which i have pasted over here so smtp is there if you want to see the errors and all then you need to active this or else comment with this so right now i have commented and this is my host that is smtp gmail.com if you are a zoho user just add zoho and the email password and its types so guys i'm using this one dummy email id so which i have created for the testing purpose so from the testing and then smtp secure and the port which is tls and 587 and now guys we are going to set from address set from and to add address so what address you are going to get from this email dollar email whatever the user gets from here okay so whatever email address you are going to give let's get back and then simple html is true subject email verification from fund of web i t and then one simple template i have designed over here which is in a h2 tag you have registered with fund of web id verify your email address to login with the below given link which is two break tags and then simple hedge tag so this is nothing but your link of your domain so my domain is over here as you can see where we are executing this right so you need to verify so whatever link you're going to verify you have to paste over here and just give forward slash i will tell verify email dot php forward slash then your verification token so which will be token is equal to and now we need to give question mark then token and this so let's create a file with the verify email let's create one new file verify email and inside this we are going to type the code to verify your email thing so let me just minimize this as simple and let's see this file is created or not over here let's type cool so now let's get back on the register so let's let's see that the mail goes so this is my mail body where email template i have called that and then simple send function and let's comment this echo and guys let's test this first so first of all we are going to comment everything comment and let's copy only this send function to send so we will be testing this let's echo that sent or not we'll keep a question so let's go refresh okay so i have logged in with this digi web next simple mail id so let me just copy this and we are going to send a mail to this same okay so there is no thing let's type with prakash phone number some random phone number and then email address make sure you are giving correct one two three four five six let's click on register now let's see what happens so sent or not we have received and let's see on this mail refresh loading cool so you can see that me and because me it's showing because we are getting from the same email id let's see you have registered with fund of fi t verify your email address to login with the below given link so let's click me click on s you can see that verify email.php with the token is equal to this is your token number so guys let's insert this data now so let's close and yep oops so let's open that gmail let's get back refresh and guys now let's comment all the things let's remove this and as simple how it was let's make like that you need to get this status so this status you need to show on register.php so let's go to register.php and show the message so i want to show of this registration form so this is my card alert i'm going to use open php close php check with the asset function where dollar underscore session of what session you are going to check status variable and if you're using session make sure you're starting with it okay so let's use a css ion session underscore start function done and now let's echo that echo in our h4 tag copy and paste set and after this you need to unset it unset function not upset it's unset copy this that's it's done so let's now let's test this get back refresh so let's now let's register so i will register with new email address we let's move to first database you browse here you can see there is nothing with prakash triple eight triple six triple eight nine the same email address i'm going to copy because i want to send on the same mail send one two three four five six let's register now email registration successful please verify your email address to login okay so you will let's check that database first so your name id email password and this verify token has come okay so guys now let's go to your mail over here you have received the mail make sure let's click on this and check that token so over here you can see that 9 7 d4 the last value over here also you can see that 97 d4 the last value okay so guys successfully we have done with this and now let's see next video about verification so when you click on this mail address that time this email should be verified so guys thank you for watching this video please continue next video about this part 3 and thank you once again
Info
Channel: Funda Of Web IT
Views: 4,583
Rating: undefined out of 5
Keywords: fundaofwebit, how to make registration system with email verification in php, registration with email verification in php, how to make email verification while register in php, how to make registration form with email verification in php mysql, registration form using email verification in php mysql, user login and registration with email verification in php, email verification with link in php mysql, email verification using smtp in php, user registration with email verification in php
Id: i1eWseYc1c0
Channel Id: undefined
Length: 19min 27sec (1167 seconds)
Published: Wed Mar 24 2021
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.