1 00:00:00,420 --> 00:00:06,090 The next thing we need to do is create the p checked out BHP page that will check the email and password 2 00:00:06,150 --> 00:00:14,030 against the database for a match so open a new file and save it as P check the IP HP 3 00:00:16,670 --> 00:00:18,320 inside your perfect cup folder 4 00:00:23,970 --> 00:00:26,910 so we'll start with our open and close p p tags 5 00:00:34,030 --> 00:00:37,060 next we'll set up the session start function. 6 00:00:37,210 --> 00:00:43,910 And this is because later in the script we'll create some session variables. 7 00:00:44,040 --> 00:00:47,730 We also need to retrieve the email and password supplied by the user 8 00:00:50,640 --> 00:00:53,790 using the post method. 9 00:00:53,790 --> 00:00:57,090 Next we create the database connection to our perfect cop database 10 00:01:02,300 --> 00:01:07,560 we then run a query on the members table to check if the email address already exists. 11 00:01:10,910 --> 00:01:17,760 So select RECORDS FROM members WHERE email equals the email variable and we'll store the query in a 12 00:01:17,780 --> 00:01:19,670 result variable. 13 00:01:19,670 --> 00:01:28,300 We then need to get the number of rows attached to the contents of the result variable. 14 00:01:28,890 --> 00:01:32,460 If the number of rows is greater than or equal to 1. 15 00:01:32,460 --> 00:01:36,080 This tells us that the email address does exist in the system. 16 00:01:37,140 --> 00:01:46,560 We then use the built in password verify function to UN hash the encrypted password in our database. 17 00:01:46,710 --> 00:01:53,110 We then compare the contents of the password variable to the UN hashed password. 18 00:01:53,640 --> 00:01:59,220 If the two passwords match we create three session variables. 19 00:01:59,330 --> 00:02:06,510 The first is log in which will store the user's I.D. and their first name in larceny. 20 00:02:06,530 --> 00:02:13,490 The reason we do this is to keep the user logged in until they decide to log out or close their browser. 21 00:02:13,490 --> 00:02:16,810 So there's there's really two ways of triggering these session variables. 22 00:02:16,820 --> 00:02:23,680 First if the user just registered and we did that earlier or if the user logs in. 23 00:02:23,750 --> 00:02:27,600 So in both scenarios these three session variables are created. 24 00:02:27,920 --> 00:02:31,990 If the entire process is executed we echo the text. 25 00:02:32,000 --> 00:02:33,350 True. 26 00:02:33,580 --> 00:02:37,810 And so that's a success code which is transmitted back to the log in page. 27 00:02:37,930 --> 00:02:45,180 If the email address already exists or if the password verification failed in both these situations 28 00:02:45,180 --> 00:02:47,320 we output the error code. 29 00:02:47,340 --> 00:02:52,880 False and again that is also sent back to the log in page.