Generate unique password token in PHP [w/ subs]



00:00:00 – okay now we have password reset HP class
00:00:03 – created and we will switch back to
00:00:05 – request new password script and first
00:00:09 – before we can start using this on a
00:00:12 – newly created class we need to import it
00:00:14 – into our PHP script we need to make it
00:00:18 – available and we do that by using
00:00:20 – require on PHP functions and we import
00:00:25 – this file which is complicated one level
00:00:28 – up outside of our scripts folder and
00:00:31 – then it is allocated inside of classes
00:00:34 – folder and it's called password reset HP
00:00:38 – so once we imported it we can start
00:00:41 – using it and reduce the first step is to
00:00:45 – instantiate this class okay then you are
00:00:47 – going i'll go password we sent equals
00:00:51 – two new password reset function in class
00:00:56 – it doesn't have any constructors created
00:00:59 – so it has an empty constructor okay so
00:01:03 – now we have password reset and what we
00:01:05 – are doing here is we're generating 10
00:01:07 – unique stream talking so i will creating
00:01:11 – you viable I'll call it a password token
00:01:15 – equals and then our reference to my
00:01:18 – password reset object and I'll call
00:01:22 – generate unique talkin with a lens of 16
00:01:28 – just like with the would-be tokens we've
00:01:33 – created for email confirmation
00:01:36 – functionality so now we need to store
00:01:40 – this token in our database and for that
00:01:44 – we will need to create a new PHP
00:01:46 – function which is called on store
00:01:49 – password talking and we will need to go
00:01:53 – to mysql data access objects and i'll
00:01:56 – scroll down here and i will declare a
00:01:58 – new function i have already prepared
00:02:01 – this function i called it store password
00:02:04 – talking so just paste it here and what
00:02:08 – this function does it accepts user ID
00:02:11 – and the talking and
00:02:13 – then insert into a new database table
00:02:16 – which we are going to create now we will
00:02:19 – call it password tokens to database
00:02:22 – table and it will set a user ID and the
00:02:26 – password talk and come it will record a
00:02:29 – new entry into this database table and
00:02:32 – the reason we are passing user ID
00:02:36 – together with this token and it is
00:02:38 – because we want to associate this
00:02:40 – particular talking with this user and
00:02:43 – the user ID is an integer that's why we
00:02:48 – have I here and token is a string value
00:02:52 – so that's why we have a data type as
00:02:55 – here because it is a string so we have
00:02:58 – installed password token function
00:03:01 – declared inside of our minds my skill
00:03:03 – data access object and we can use it now
00:03:06 – here to insert the to store this
00:03:10 – password talk in our database so I will
00:03:14 – reference to my data access object and I
00:03:17 – can call this function which is called
00:03:19 – store password token and it accepts a
00:03:22 – user ID and a token our token is called
00:03:26 – password tokens I'll copy this
00:03:28 – comparable to paste it here and how a
00:03:31 – user ID is not declared but we have user
00:03:35 – details retrieved from database and
00:03:39 – stores and user details very ball so i
00:03:44 – will copy this user details and i can
00:03:47 – either paste it here or i can calculate
00:03:49 – in your viable approach user ID and this
00:03:53 – equals to user details and i will read
00:03:56 – user ID user ID from this at HP array
00:04:02 – which is user details and it's very
00:04:05 – important not to change order of our bar
00:04:09 – balls here so when we call store
00:04:11 – password token function on user ID is
00:04:15 – the first and the password talking in
00:04:18 – the second and if I click if I go inside
00:04:21 – the store password token I need to make
00:04:23 – sure that user ID goes to first and then
00:04:26 – the token goes to sign
00:04:27 – if you switch order between the so that
00:04:30 – will be in there and it will not work
00:04:32 – okay and once we have returned value we
00:04:36 – need to return it back to our script
00:04:41 – okay so we have a function on store
00:04:46 – password token function ready but we do
00:04:49 – not have password tokens database table
00:04:53 – so we will need to go now and create
00:04:55 – this table


Video Url:
http://youtu.be/OZKLpHIho9w

Comments

comments