Pending Request Accept/Decline User Acc System in PHP and MySql Tutorial with Source Code

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so how does this pending request bugging works here in database and let's go to accounts table you already have an email account Joe Acho that come in to us with Joe and here if you're looking here Joe Joe calm password Joe Mixon in now never so high admin is the type in the base so no pending requests yet because we have been gone in activities yet so let's click lock up so you click logout it will it will not go back to home the PHP anymore because we log out already I will just redirect us again to plug in the PHP so let's try to create an account let's name it just name it with a friend named Jeremy and rota so Jeremy wrote that and yeah so the password will be hey Jeremy so quick sign up so you can see your account request is now pending for approval this wait for confirmation thinking okay so let's go back to login page let's try to login Jerry Marotta so let's see if it's already registered wrong login details therefore that count has not been registered yet because it's not even accepted yet maybe admin so that's like in the admin which is Joe now here you can see Jeremy wrote that is that calm would like to request an account so it's either we will go in to reject this or we're going to accept this so for this time let's see it says let's accept this right let's click accept and now account has been accepted if we go back no pending requests because we already have accepted the request okay so let's try to log out like this up now let's open Jeremy wrote at least that calm let's see the password sure same in so as you can see he's a user and opening request and he is already registered and now let's try to create a new account for this time is going to recap this let's name it John it's a begun runs a bigger an add-on Archie calm yeah here password will be John let me get shot send up so your account to cussing up anything for approval click ok so let's go back to login page and let's try to sign-in Joe a product so same in so you can see submission would like to request an account so accept or reject so in this case we're going to reject this request let's see what will happen so click reject and now account the spinning ship so go back and open the universe like out if you try to log in gentle began its read gentle be an energy that calm I saw John wrong looking because because it's a found it's not meaning deserted because it's been rejected but I'd mean so let's see in the database as you can see only Jeremy loved Angela bhai still stop are da bounce here request so to start let's all that xampp control panel so let's start in Apache server and MySQL module so here start SQL Moodle now let's wait for it to load to make it clean alright it's great now close this now let's open your browser so you can open whatever browser that's for me I'm gonna have the Google Chrome so now let's go to get bootstrap calm we're gonna um get some template there because I'm not really good at front-end so go ahead and get bootstrap you can actually use your website or whatsoever for this one but for me I'm gonna use bootstrap now I have this sent in template so just select view page source as you can see copy this one and open your code editor for my code editor I'm using rockets at i/o but you can actually use whatever you want not bad don't know what's my best less or whatsoever and now paste your thing wait wait that's gonna wait for this to load so now go to file and open a folder so here opening folder so go to your exam next Docs to be specific exam or gassy exome htdocs so now here make a new folder name it whatever you want but for me I'm gonna name it pending requests pending pending request system oh sorry running ecosystem and that's it now click the folder like this oh wait now select the folder now everything you work in this rabbits will be automatically saved in the no new file let's paste this and let's name this as login I know yeah login login that PHP so click Save so here now let's renovate the side let's change this bags CSS tags to bootstrap so let's go to home and scroll down a little bit so CSS here copy the CSS and replace it here and put it in the head tag paste and there we go now erase the other one they're not necessary and also this thing next click Save and now let's copy the script skip skip also heart essential so copy the script and now put it inside your body in the lowermost part so here and let's have an invention so great perfect so let's save this and now let's go ahead go to your localhost / pending request system so that's the name of my budget folder in htdocs' so there and see it again that patriot let's click this as you can see we already have imported the posture but now I'm gonna make a container container here to make it really so expensive and so need to see so container the container and close this container to the end of the form so click Save oh no wait we have an intention and perfect so safe and so fresh and I guess it's great so now let's get rid of this remember meeting below so here that one so let's just erase this one so erase this sniff okay now do the dead so you can see it's gone the next one I'm gonna create a link here let's replace this a link to the signup page so we're gonna have a sign-up page so for 8 and the town here and make this a a tag okay and then save now let's go to H ref and sign up that PHP so yeah click Save and let's see let's refresh its you see great in the family if you click that one I've checked me fun because we still don't have a sign up the PHP so let's create one here so now just copy everything here and go to new and paste everything and let's renovate this as sent up that way tree so safe I sent up the PHP and now let's erase this one and change to sign up yeah and then fresh as you can see please sign up we sent out the page next one let's erase these things I mean just copy this one copy and then yeah here put it here yeah so let's change this the first name and let's paste another one and put this as last name that's me Oh perfect so oh wait I still have don't talk to face all the church also the placeholder let's change this first name and another for this one is last name so so fresh and that's um let's need to what else should we do here this thing we need to change this button it's changed is to sign up also change this one to go back to login page and as you can see and also this href changes to login that page we not refresh let's see what happened and you can see you now go back to the impeach so here that's it so now what we're going to do is to just go to examples and click this out boom template so here we're gonna use this correct click and view page source so right here and copy all this stuff just ctrl a 4 select all and then control B for a copy so create a new file and paste it here I will save this as home that page P so this one will serve as our homepage for our pending request system so now let's find something like wait let's delete this one we're not gonna needing this so go to home the page we let's see what is happening steam so now go to home and let's copy the CSS file I mean this link and paste it to our head tag here and like this and erase this unnecessary CSS link and also this fabric on and now scroll down and let's replace these scripts here to new one so let's get rid of this one grace and peace now yes that's it let's refresh our as you can see it's now changing to something awesome so let's erase unnecessary elements the footer below and also let's change these elements here see all right also this one I don't like this button so it's this button and the fresh and you can see the button is now gone and now also change the weight here there is this one Save there's no icon anymore so next one I'll change this to sort of change hi admin yeah the services are great things for homepage refresh and you can see it now name of the requested so here below let's change this to something as saying a message like his message here oh no no no hi hi I would like to join your website please accept my request I said so as you can see here is the name of the request D and then it's the h1 I say let's change this agenda and below is the message of him saying that he would like to join the website now let's change these two buttons to accept and reject we're gonna add functions later so here that's it now what else should I do let's make a div class cool right yeah so this div serves as let's change this a tags tool button so the change is the button because button makes a function here so just logout so here and I want to make this red so let's change the primary to danger this is for the basic bootstrap yeah as you can see it's now red so let's let's have a temporary link as like in the face B so click logout and wait what happened all right let's change this to a tag I'm sorry so refresh and lockouts as you can see now what we're going to do here in the log in the PHP will make a function if finish let's make a function so all host / HP madman first go to your database and go ahead and make a new database as for me I'm gonna name it pending request system then request alright so change the collation to utf-8 general CI adhere and great so nice processing and now that database has been created so now create the table name users oh no no accounts because we're gonna have multiple accounts so now for the first field let's have an ID next one will be the first name the first name of the account the last name and then the email so let's add three columns next one would be the type but what type of account is it's either admin or a user so let's change this to in and let's check how to increment so uh tournament will be automatically be a primary key so let's change the other things to text also the email and also the type as text and it's gonna have a new field for a password same same with the other one make a text and I guess that's it so it's saved so as you can see the table has been created now named accounts so now let's create another table for requests this table will handle the requests from the from the request e for those acosta will be requesting for a new account in a website so let's have ID first name email last name and it's gonna have a date oh wait password and lastly it's the message and of course last is the date all right so let's change the date to date time press it here exchange the first name with text as well as the last name email and the password and also the message let's make it auto increment go primary key so now let's save this alright we have now a request table now let's make a function let's make this form fashionable make a method - method post and let's insert something here in PHP let's make the names for the input tags so here that's a name email next one name password for the input password field so next one for that button let's name it sign-in that's it so next one you guys that's it so let's make a function now here PHP opening tag and then a closing tag let's make an F so if I said host signing so if the bat consent in will be clicked a function will with a call or happen all right so let's create the pension function so the password let's make a variable that will hold the data of the input type password and also for the email and now let's just save this for a while and let's make a new file for the functions this file will will hold the functions of our pending request system so let's name this function set VHP now let's make a sabbatical this let's define a constant constant variables are the variables that cannot be changed so let's first name is name this DB info this constant variable will hold the information of the database the host name and also the database name so the name of their database is spending request request system and the host is localhost and now let's define the DB user it means the user of the database so now it's default as root and the password is none so just leave the password blank and now let's create our function first function is performed query this function will have a parameter of query this will hold the query parameter to perform something to happen in the database so this function will manipulate something in the database either you will let or add or whatever things you want so let's having first con equals new PDO and let's put the constant variables here the DB n fo DB user in DB passed another straight new variable named esteem T so this is temp T variable will hold prepared connection to the database and so that it will outperform something in the database so now if the SMT executes once this is the empty variable will be executed it will return true else it's false so let's save this and now let's make a new function this function will fetch the data from the database so this will bring the data to the though our PHP files from the database so the same parameter is the query so with the same also connection con variable with new PDO so whether we are I'm not using my skill I because my skill has way it's very hard and I guess video is more easier and I mean it's easier so SMT L returned as the empty fetch OH so this will fetch whatever data that is in the query parameter so now let's go ahead and go to our login page and let's create function in this once the button sign in will be clicked so let's make a query let's select all from accounts I mean users yeah so here this query will select all the data from the users so that's for H this one because the the data from the fetch all from the database is already so we're going to use for each loop for each loop is used for arrays and now let's have this for H a fetch all I mean so first I forgot to include the functions of PHP don't you ever forget to include the functions that PHP at the top of your page free files so include the include functions that PHP so now also I want to start the session because we're going to need to be to need the session for this one so yeah we need a session for dialogue in thing so that's it now let's make a function here if I wait yeah I forgot to put a stroke so now if row email because email never if the email that the user input in the input type in the input type text with the name email is true and also the password is founded database therefore it will redirect this thing to the home page to the home that PHP so let's put a session log in true so therefore if it's true if the email is correct and the password is correct the session plug-in will be true and it will go to the home page if not if the details are wrong so it will trigger a JavaScript alert wrong let's let's step in here step in here wrong login details so that right that's it so yes that's it so let's add another if for catching the error so if fetch all if can't fetch all query is 0 is greater than 0 so the for H will be triggered actually this if statement is not really necessary this is just for error caching so if you don't want an a bag or something just need this if F if statement so let's make on health for this one if else let's put in here a JavaScript let's trigger JavaScript but let's change the alert to something like so yeah I guess that's it so this is for just a patch unknown so that's it so now let's change this to select all from accounts because I forgot it's not users table it's about sign-in so you can see it's error go to accounts and browse error because we still don't have data in the database so let's go ahead and make a data so first name Joe last name will bill abajo and then the email Joe at show that cup the type is admin so that made of the page so let's have a password with Joe so go and it's loading so here it's a row inserted so let's try to login so at Joe that come and send in so as you can see I've been redirected to the home page so now let's have this create account let's have this synaptic page we work so go ahead at the top copy the top here alright so from the other in page login that PHP the session start and also the include wash as a PHP so now let's let's make this form method active form method post' so now let's change these things let's take change the type to text the thing in here is that to make your HTML interactive to the page for files so let's make a name just like what we did in the login page before so name last name here you email right that's it so for the input type let's name it password the password field so for the button let's name it setup so let's create now the page free function it's a PHP opening tag and a closing so if he said if the button is clicked so this will trigger an event so let's have this if it said send up first name because so this first name variable will hold the first name beta function from the text field first name the last name will go as the same so let's go ahead and type this things up so for the password that's just with this password so the email for the email and lastly the query so for the query we're gonna have this go to insert database and just go ahead and preview SQL this will trigger e Emoto that will have this one so it's a built-in something-something right here it will insert this query will insert values I mean data from the page we file from the display page or the browser to the database so let's go ahead and fill this in for the date I just put in current timestamp because there was this will insert the time the current time of the data I mean the current time of the user in this time does it make sense I don't know but that's just what the message lastname firstname would like to request not so for the message let's go hear the message yes I guess that's it that's yeah let's save this and let's close that one let's go to functions and now we'll go into perform a query therefore instead of the PHP will have a if perform query if that if the query will be successfully performed inside the database it means if the data that has been inserted by the user in the same of the page we will be successfully inserted in the database this script will be will be triggered the other script script will be triggered your account request is now pending for approval please wait for confirmation thank you so I guess I said else if there are unknown error occurred let's let's just trigger and JavaScript event alert unknown error occurred so yeah here semicolon and that one so let's go browse and as you can see there are still no data yet so let's try to see if oh wait there's an ER I forgot the alright next pocket so filled in the take jgl abajo and using a version or so sign up you can see it successfully inserted in the database your account request is now pending for a Krupa oh wait there's and her still let's debug this one and if I'm variable password let's trace the bug is it it's right all here yeah the password as already as all that's changed yes you can see the password has not been inserted because the password here has only one s this uses let and try the new one so let's fill this in JJ last name and is George an opportunity that comes up a surge oh it's an up you can see your Afghan trees best up in the fall over so they're now here it successfully inserted in the database so the password is Joe and the message something like this so date is also inserted for the current time so now let's go ahead and go to your logon page and try to look in the one you can see what we're going to do is we're gonna so just go ahead and drop the page fitting about the synaptic PHP and just paste this to home that PHP so here now we'll edit something here let's change this to ending requests system in PHP and MySQL save this the title and that's just not gonna need this part so let's let this row mr. I mean so they let and now I guess I'm not needing this too so delete and also I guess this one yeah let's just delete this one too so they're late and safe so let's refresh and as you can see there's nothing to do with that one so let's change this admin - well it's gonna have here in PHP let's make a session data I mean session variable let's make a session or you're gonna name type so this will hold that type type field of the database for example here let's just echo it here PHP tag echo session type so something like this so fee like this out and type in Joe at Choate calm Joe sent in so it's QC it's user because it's a type of the data inside the database so how about if we change this to user go to accounts press wait for a moment so here let's change the type to user if we save this and let's refresh let's logout and Joe Joe calm and type in Joe as you can see it's been changed because it's in the database we have we retrieve something from the database so now let's change this to admin because we're gonna keep Joe as admin so that they can accept and reject accounts so itself in here so as you can see it's already dead man and now what we're going to do now is go ahead and change this gender to people okay let's let's go ahead and change this button which no and it's got a name back up and let's make a form so that this button will be functional so post from post just edit this in tag and just paste it here and as you can see it's here so now we're gonna make a function and uh like up button so just make a page we talking here it's absurd if he said blackout post lockout just like out it means if the if the button like up will be triggered the button like that will be triggered it will make a function in here so let's make a function in it let's put session and destroy so this function will destroy the session the current session of the of the browser so it will lag the thing out so here we're gonna also insert something if you're if session oh it I forgot the dollar sign let's go session the session log in is true location location all right I mean he had a header side here is location again that page me so here have this out straight up so let's step in here oh yeah so session destroy I guess it's functional so let's go to home that PHP you can see it will want it will not go to home that PHP through the URL because we have updated it to something so now then I got button is now working just putting session destroy' so let's also put a header location home that PHP so show the show that song you can see it's automatically be redirected to login that PHP so now we're gonna change here it's gonna make this accept and reject button worked so let's make a function here I guess it's fun already so let's just copy this one and paste so you can see it's just like that there's so many now so now let's also have a page pin here to end our statement so now let's go ahead and get copy this one just got paid this one I guess that's right alright so now let's make a variable query so we here select all from from requests here so we're gonna grab the things in here from requests to our PHP file to display it so for H so we were gonna use for H because our query is is returning a array array function already data I mean so let's fetch all very so put the parameter as query now let's count this here so now if the count is greater than zero the 4-h teen will trigger so 4-h let's have this and all right let's put this inside the 4-h where is the one so so let's close the PHP and open under one and that's inside let's put this inside the 4-h so let's have the intention to make it neater clean now let's go ahead and and call the function veg all with a parameter query as this will not forget the ass rope so now inside here we're gonna echo how it let's put an else first so else echo no ending requests all right so therefore if there are no data inside the database the no pending requests will be displayed there so now let's echo the row name I mean email let's just put here the email wrong email we copy this one and I want to paste it here so on a piece here the message Oh message and now here for the button that's gonna erase do something Oh what should we do all right let's put here the date the date of the thing or when the request has been made so let's throw date you know that's refresh it's an airline 69 let's debug this one oh yeah I forgot the semicolon so here I put the semicolon and then refresh as you can see she's in the budget gmail.com we like to request an account except reject and also the date is shown here below from here so it's let's go to the quest table and the database so you can see everything is so accurate and also the message it's so awesome so now let's make this almost an email and then here on Sunday so now let's make this accept and reject button work so how are we going to do that in order to do that let's go ahead and first is a href to wait wait wait change this button to a tag so let's change this to each I don't know except that a HP with an ID let's echo here the ID so so in here what we are doing is we are displaying the ID in the URL make using the request when get request function so let's echo there oh wait wait wait row ID yeah so save and now copy this one just visit here so you have a reject that PHP question mark ID is equal to let's just copy this one because it's just the same paste and it's fine now let's say this this except boppin will accept the thing and go to accept PHP and it will accept the thing but we still don't have the accepted PHP and reject the vegetable so let's create a new file this one is for the except that which save I've been here except that page be saved and now make an under file and name it as rejected PHP so reject that H be safe so now let's create a function inside that except that PHP what we are going to do now is the yoga [Music] okay we're gonna make this accept so you can insert it to the database if if your thing is accepted so echo this really accepted thing so here you can see except that the HP stream rat ID Scott the truth so now let's get the ID from the URL so let's make an ID variable to get the request in the URL so to get the ID in the URL just called the get method ID so now if I would have a query first so I carry weight to make the word accurate so let's offset that thing oops so now let's create a query here select all requests where ID is equal to ID just put in here the variable ID from that one that we get from the URL so here saved and now what we're going to do is the one make an if statement with this statement I mean for each because we are going to have a fetch all so we're gonna use 4-h because the fetch all method is getting a a data that is array from the database so for H which all various roof so here it's wait what should be put a query second query oh wait that's just a pneumatically so query this query is another new query will be triggered after the 4-h statement has been made so let's go to your accounts database go insert and go here below and click this preview SQL right just copy this code here this is good code and paste it to query so let's go ahead and fill these things in so the ID just let's just leave it null for the first name we're gonna have a row wait wait it from first name because row of course with an index first name and then the last name row with the index last name and the email row with the index email so save and also I guess with the password thing so here serve this here a password because row password alright perfect so let's fill this in the query here the first one is the first name first name second one is the last name and third one is the email and next one is the type the type let's just say there's a see you sir so the lastly is the password so yes that's the query now let's make a error holder so this F will hold an air if the fetch if the if the fetch thing is not equal to naught or not later than 0 so if it is greater than 0 the four-h will be triggered so copy/paste and it should have an indention shown here so face save and miss this megan else echo echo here error an honor record yes so error just type in here error like that and I guess that's it so now let's make another query I don't if same thing so let's make a little query in here this query will will concatenate it means that it will add up the first query variable to the second one so in account we're gonna have to delete this but just don't delete this just copy the query the lead from requests where IDs like that so piece it here so it will be deleted from the request table so just change this to ID wait let's put it inside like this one here so now let from request where I crossed IDs like that just so now if perform query with a parameter query it's true echo Oh God that's been accepted period so semicolon let's put an else statement so if there's something wrong that happened just echo unknown error occurred so please try again later I know just please finish next one I guess that's it that's for everything ok copy this one what an urgent so in reject that PHP it's just simple look like that I also of course just copy this thing I know this thing because so that URL will be will get the ID here so save now let's change the query let's do that concatenate and SS that's perfect such distance is projected I mean period so save and then let's see if the thing is working so let's refresh let's click accept oh oops there's some under 1981 so let's go to fashion is at page B I mean except FHP oh yeah I forgot the semicolon thing getting so let's go back and refresh it's except I'm cold air flash all thrown by than 5 so then fly what's happening mmm unknown code and then face yeah I forgot the function set page so you guys don't forget to include the functions that page B because it's really important he is not recognizing the fetch all function because the rushes of a tree is not been included in the thing so it's also make a a back a tag in here so let's back and then href the chase ref is the home let me just copy this thing and put it also in the except at page save and now what we're going to do is [Music] I guess it's fun already so let's try it again refresh and - so except I can't accept it it's great so let's check our database let's go to request as you can see from request it's been deleted and let's go to accounts and as you can see it's been added to the cards because the thing is already accepted so now let's back go back and try to another turn another one it's exactly the one go back up and it's that's I guess open the thing to create the true I mean yeah here not even children the Virgin Mary me let go so as you see it see you sir it's it has now an account because it's been accepted so let's create a new account let's name it Irene of our Irene Irene that come specify a serene setting up your card is now pending for approval so let's go to plug in page and try to plug in the Java child that contain accept so what we're going to do is we reject Irene for now forget so reject you can see counterSpin rejected go back and if we can see here Irene has not been added in the accounts table because it's been rejected and also it's been the little inside the requests table so yeah I guess that's it guys so I hope you learned something [Music] [Applause] [Applause] [Music] [Applause] [Music]
Info
Channel: JJ Labajo
Views: 32,178
Rating: undefined out of 5
Keywords: php, programming, web programming, web developing, web dev, web development, php programming, mysql, database, pdo, programmer, joejune, developing, development, beginners, tutorial, tips, tricks, how, to, howto
Id: 5YgscpAC0gE
Channel Id: undefined
Length: 53min 46sec (3226 seconds)
Published: Wed Feb 14 2018
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.