Okey, jadi hari ini adalah sebuah ketiga sesi. Jadi, seperti biasa, bagaimanapun bagaimanapun setiap sesi, ada lebih banyak orang dan ada... Ya, tentu saja. Jadi mungkin ada sesuatu sebabnya. Biasanya seorang yang berbicara, atau sebab yang kedua adalah bahawa mereka tidak dapat maklumat di sini lagi. Yang mungkin juga bermaksud bahawa orang berbicara. Tak ada masalah. Saya mungkin bukan seorang yang terbaik atau apa-apa pun, tetapi saya cuba. Jadi, pentingnya adalah yang kita cuba. Jadi, kerja kerja 3. Kita akan bercakap tentang kedua yang kedua untuk PHP dan javascript. Kedua yang kedua untuk javascript, tentu saja. Sebenarnya, ya. Jadi, ada beberapa halus. Tak ada makanan atau minyak. Di tempat ini, ya. Dan kita mempunyai air minyak di sini. Untuk mempunyai diri sendiri. Password Wi-Fi. Password Wi-Fi SSID adalah Ninja dan Password Password adalah Password, tentu saja. Jika anda penat atau ada sesuatu yang anda boleh... Dan anda tidak rasa seperti bertanya, mencari tangan anda untuk bertanya. Anda juga boleh beritahu saya bagaimana menunjukkan platform ini yang mencari tangan anda. Anda boleh beritahu saya pertanyaan, tetapi saya mungkin tidak menjawab mereka. Tetapi, apapun pertanyaan biasa, apabila saya melihatnya, saya akan menjawab dengan cepat. Jika anda tidak rasa seperti mencari tangan anda untuk bertanya, saya akan mencari tangan anda untuk bertanya. Saya sangat mencari anda untuk bertanya jika anda ada apa-apa. Kerana jika anda hilang, dan seseorang lain juga hilang, dan bagaimana anda tidak bertanya, bagaimana anda akan hilang, dan bagaimana anda tidak akan kembali lagi. Jadi saya akan mencari, dan saya akan mencari sepanjang hari. Jadi, jika anda ada apa-apa pertanyaan, jika anda ada apa-apa, jadi, saya akan mencari pertanyaan saya. Jika anda tidak melihat saya sebelumnya. Nama saya Wei Ren. Saya seorang penjaja penjaja di Singapura, tinggal dan minum dan makan di Singapura. Handelur saya, anda boleh beritahu saya pertanyaan yang anda ada. Jika anda ada pertanyaan tentang web, web program, apa saja, anda boleh memberitahu saya, atau anda boleh tanya saya pertanyaan jika anda suka. Jadi, kita bersama untuk hari ini. Kami akan membantu kita dengan lelaki di sini. Dia akan membantu kami juga dengan pertanyaan anda. Jadi jika anda ada pertanyaan, terima kasih untuk mengambil pertanyaan kita. Jadi, hanya yang kami lakukan sepanjang hari ini. Hanya yang lelaki yang terkenal untuk menonton, siapa yang pertama datang sini? Tidak ada. Okey, bagus. Jadi, ini adalah recap yang kita belajar lalu. Kita belajar tentang desain responsif. Jadi, bagaimana kita dapat menggunakan MaxWare, bagaimana kita dapat menggunakan perkara ini untuk membantu kita memastikan website kita untuk menjadi lebih kuat untuk desain mobil dan desain tablet, dan lebih kecil, untuk menggunakan pemeriksaan. Untuk membuat pemeriksaan untuk semua platform dan mempunyai baik, kerana apabila kembali ke mobil, kita perlukan gambar untuk menjadi lebih besar. Kita perlukan untuk mempunyai pemeriksaan yang lebih besar. Jadi, kita juga belajar tentang PHB, operator dan EVE-L statement. Jadi, jauh-jauh-jauh, kita mempunyai dollar sign yang adalah pemeriksaan untuk variable. Jadi, dollar sign untuk variable yang lain adalah 5, yang menyebabkan pemeriksaan. Jauh-jauh, ingat bahawa anda mempunyai pemeriksaan angkuh untuk menyebabkan pemeriksaan dari dokumen PHB. Kita juga belajar modul-s seperti itu, EVE-L structure. Jadi, EVE-Ls, EVE-Ls, sebagainya. Jauh-jauh, ingat bahawa ini adalah pemeriksaan logis seperti ini. Jauh-jauh, anda mungkin tidak ingat segala-galanya dengan mudah, tetapi anda hanya perlu tahu bahawa ini adalah pemeriksaan. Anda tidak perlu tahu apakah pemeriksaan yang benar. Tetapi anda hanya perlu tahu perkara ini adalah pemeriksaan. Itu adalah sesuatu yang anda mesti berhati-hati. Dan juga adalah pemeriksaan. Jadi, 4 pemeriksaan, 4 pemeriksaan, ada 3 pemeriksaan yang berbeza di PHB. Dan tentu saja, kita mempunyai pemeriksaan URI, pemeriksaan POSU. Ingat, kita mempunyai GAT dan POST. GAT dan POST adalah pemeriksaan yang berbeza yang juga digunakan, dan sebagainya. Tetapi, ingat, ada pemeriksaan dan GAT. Jadi, pemeriksaan yang benar-benar adalah GAT dan POST. Untuk GAT, seperti anda tahu, pemeriksaan dapat dibuat. Dan, pemeriksaan di URI untuk POST, tidak diberikan. Pemeriksaan di URI. Jadi, itu pemeriksaan yang benar-benar yang kita belajar tadi. Kita akan bermain game, seperti anda tahu. Jadi, kita mempunyai pemeriksaan untuk anda bermain. Dan kita mempunyai pemeriksaan untuk diberikan lagi. Pemeriksaan yang sama, yang kita tidak diberikan. Baiklah. Jadi, saya akan memperiksa pemeriksaan yang benar-benar. Baiklah, saya rasa... Jadi, anda memperiksaan saya? Baiklah. Ya. Ini adalah... ini adalah masalahnya. Biar saya memperiksaan saya dulu. Baiklah. Biar saya memperiksaan dan memperiksaan. Pemeriksaan yang benar-benar. Biar saya memperiksaan. Boleh kita? Boleh kita memperiksaan? Biar saya memperiksaan untuk... saya beritahu anda. Bukan. Dia akan memperiksa. Baiklah, jadi... Baiklah. Saya akan memperiksa. Saya sudah memperiksa. Pertama. Biar saya memperiksa. Awak tahu mengapa awak memperiksa? Awak tahu mengapa? Dia tak akan memperiksa. Tidak. Saya akan memperiksa. Apa? Ini pemeriksaan saya. Apa pemeriksaan awak? Awak tak kira ada seseorang yang awak kira tahu. Biar saya memperiksa. Biar saya memperiksa. Ya, ya. Jadi... Mari kita mulai. Meniakkan com.it. Meniakkan. Ini kan saya panggil com.it. Sebenarnya... Ya, ya. Ini cakap com.it. Com.it? Com.it. Jadi, saya rasa kita ada satu god. Jadi, god berkaitan dengan... orang selalu melihat god berkaitan... ...berkaitan. Sangat kencang, kan? Jadi ya, KAHU.IT semua sudah berminat? Bagus. Jadi mari kita mahu bermain. Dan kemudian ia akan membuka dan akan ada kode di sana. Seperti biasa. Sejak kamu... Ini bukan kali pertama kamu di sini. Seperti itu. Jadi ya. Okey, jadi kode... Koneksi. 7, 9, 4, 1, 8, 1. Waktunya beli 40. Baiklah, ada 60 jenis. Baiklah. Jadi... Kita ada... Kamu tahu? XD SK, KF. Smallly Face, 404dB. Apa? Baiklah. Nama yang sangat kreatif. SM. Nama yang benar, saya rasa. Jun Shin. Okey, saya rasa ada seseorang di sini. Baiklah, bagaimana banyak orang di dalam bilik ini? Sebenarnya. 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17. Jadi kita patut ada sekitar 17, kan? Jika ada 18, itu... Wow, betul? Nama saya? XD Jadi 17, mungkin? 17? Semua orang, betul? Baiklah. Baiklah. Baiklah, mungkin saya... Baiklah. Sekarang saya buat senjata. Jadi itu saja, kan? Ya, itu sepatutnya. Saya akan press start button. Start. Okey, jadi... 19 soalan, wow. Jadi... Apa soalan yang menjerit? Ini sangat mudah. Soalan yang menerima penggunaan penggunaan penggunaan yang beri pengalaman. Penggunaan penggunaan penggunaan yang beri pengalaman. 7, 6, 5, 4, 3, 2... Baiklah. Soal 8 orang, kamu dapatnya? Baiklah. Itu kurang dan segera. Sangat bagus, saya rasa. Okey, jadi... Soalan yang menerima penggunaan penggunaan penggunaan yang beri pengalaman. Saya tak tahu apa yang saya kata. Soal yang menerima penggunaan penggunaan penggunaan penggunaan penggunaan penggunaan yang beri pengalaman. Dan juga... It's really about designing different, so there's this term called UX UI or whatever you want to call it, so UI represents, what, what, what, what, UX represent experience, right? So people design like UX experiences, they call themselves people who design for experiences, design for something. So yeah, using media courage and all, you can do that. So, wow, we've got two that is one, right? Ha, ha. And we've got me living in a fifth place, right? Apparently I'm playing, yeah, right? So why is responsive design important? Anyone knows? I don't know. So that everyone will be able to build your site, ensures ease of accessibility across platforms, ensure good UX across platforms. It isn't important. So I think if someone presses like the green one, they need to kill themselves. Okay, so luckily we've got zero here and majority are correct, right? Okay, so it's website, right? Everyone can view your website as long as it's on the internet, right? And everyone can view it, right? Whether or not it's designed for the particular screen, it's not sorry, right? So that's the thing we want to focus on. And that's about ease of accessibility across different platforms, right? And of course ensuring a good user experience. Ah, I remember what UX really, it represents user experience, right? User experience across platforms, right? So we've got D-bowl and 2, finally at 2, right? And I'm in the fourth place, right? So question number 3, how can responsive design be achieved? Ah, this is so easy, right? I think by flipping tables. Hmm, questionable, right? Yeah, let's see. 7, 6, 5, 4, 3, 2, 1, 2, using media query, right? So, okay. Okay, so responsive design is achieved using media query. So media query specifies a max width, the style for certain screen size and all. CSS max width is just setting a property. It's just a property by itself. It doesn't mean anything. It's just setting a property, yeah. So don't be confused between these two. Responsive design can be achieved through using media queries, right? Ah, we've got, well, I'm going up the ladder. Okay, so question number 4, what is bootstrap? So we mentioned about what is bootstrap last week and if you probably maybe listen to it, you might know, right? So front-end library, bootstrap framework, front-end framework, site designer. It isn't that hard, right? I think. So, okay, not that bad, I guess. So, okay, it's not a front-end library because it's a framework. It's not just a library. It's more than just a library. JQuery will be a library because it's a single JavaScript library. But as a framework itself, it's something that helps you do heavy listing at the beginning and also do a lot of heavy listing for you, right? It includes CSS components, JavaScript components and things like that that helps you do a lot of heavy lifting and a lot of design and colours are already incorporated into it. So it's a front-end framework by itself, right? It's not full stack. So full stack is... What full stack means is that it's front-end and back-end, right? So it's only purely front-end and not. Okay, so of course it's not the site designer as well. Site designer tools will be something like weeks or something like that, I guess. Okay, so that's really it. Okay, I dropped. Okay, so what does bootstrap not include? It's just hard. CSS, Webpack, jQuery, React.js. Oh, this is a bit hard. What does it not include? I say not to answer just now. Done. Alright. For three. Okay, so it's not... Okay, so pretty good actually, I guess. So most of you know what it is, right? It's a front-end framework that has both CSS components and JavaScript components basing on the jQuery library. Actually, it doesn't really include the jQuery library itself, right? Shit, but okay. Webpack is the tool that allows... That's for building that you might... We probably would be learning in the second part to JavaScript, probably, maybe. So it's a tool that allows you to do packing and stuff. So React.js is a library by Facebook, currently your Facebook.com and all that. They use React.js and probably not jQuery. Okay, wow. I'm so straight. Who's Dibble? Okay. I don't know who. Okay, so in bootstrap grid system, how many columns are there in two rows? 34? 21? To trough? 6, 9. What's 9 plus 10? 21? What's 9 plus 10? 21? Okay, so the answer is 24. So if you... I said two rows, so if you take two, multiply by trough, you get 34. Yeah, so... Most of you know the answer just that I said the two rows and... Yeah. Okay, so... Okay, that did the work. Okay, so Dibble is no longer leading. Should bootstrap be used for very small projects? Why? Yes. Yes. Maybe. No. I don't know. Who cares? 4, 3, 2, 1. Oh. Okay. Um... I think I didn't teach good enough. Last week. Okay, so... It does accelerate initial development work. It does simplify cross-device design. At least you didn't chose the third answer. Okay, so it does this too. But it should be used for very small projects because it's very large in size. You have seen how many kilobytes it is. It's like 300. And then you have the jQuery library and stuff. And it's really, really huge already. So it's really bulky. So if you're really doing a very small project, you should be just writing your own CSS styles. And that should be it, right? So... Yeah, so the correct answer is no. It's very bulky and slows down the web. Okay, so... Not a lot of people got it correct. Okay, so now we're on to the PHP part. What is PHP? Alright, so... A very simple question. Oh. I didn't put in simple answers. A server-sided pre-processing pre-part language. A server-sided pre-compart language. A server-sided pre-processing scripting JIT language. A server-sided pre-processing scripting interpreter. I'm out of breath already. Time's up. So it's the fourth answer, actually. So it's... It's arguably pre-compart. But it's more of a... It's actually an interpretation. So initially, when I explain about it, so when the user visits the website, so what happens is that the user will hit a party. So a party will then send a... See that, oh, it's a PHP. And then it sends to a PHP interpreter. I said PHP interpreter. Of course it will be an interpreter language. And why is it a pre-processing? Because it pre-processes the request and then outputs the information out. So there are languages that are more pre-processing, such as Python. They are not doing pre-processing and node as well. Node doesn't do pre-processing. So it's a server by itself. And it's of course a scripting language. The first person didn't get it correct. So no worries. What does PHP stand for? Does it stand for human rights? Pre-hypotex processor, pre-hypotex pre-processer, BHP, hypertext pre-processer, post-hypotex pre-processer. Okay, so how many got it correct? Okay, not bad, I guess. Quite good. It's a recursive acronym. So you got PHP, hypertext pre-processer. So it's PHP. Do you see it? We do it. It's not PHP like that. So that's it. There's no explanation to this. It's just a definition. Okay, so the first person. What is this? I war. It's the highest climber. So I'm wondering if this person has climbed Mount Everest before. So to run PHP, it needs dot, dot, dot, dot. So like, no, when people send me messages and then they like, they always put this dot, dot, dot behind, then I'm like, what, why? Then like okay. So what is in it? What do you need to run PHP? Do you need electricity? Time's up. So okay, we got a not very good split actually. So it needs a, we've showed the diagram before. So okay, so the quest sends to the web server. The web server then send to PHP. It knows that it's a PHP file. Then it sends over to PHP interpreter to interpret it. And then send it back to web server to serve it. So it requires only two things. PHP and web server. Just like this for the PHP 5. Whereas PHP 7, you can actually run without a web server. I'm glad none of you chose the blue one. That's good. So it doesn't need a database run. Okay, for a minimal setup, you only need just this two. You don't need any database, right? It doesn't need HTML to run either, right? Okay, so the first person still hasn't increased, which is a good and bad thing. Question 11. How do you begin a PHP file? Of course. So easy, right? There's no need to begin it. Wow, that's fast. Okay, good. Wait, really? Did someone really chose this? Okay. Good. It's good that majority of you know that. It's a angular bracket, question mark, PHP, right? Give away question, right? So easy. How is a PHP variable declared? This is easy. This got some variable equals low. Some variable equals low. Low. So majority got it right. So this is in the underscore format. This is in the camel case format. Both are correct and it will work. But in PSRs, or PHP standard recommendations, it's preferred to use underscore instead of camel casing. So technically speaking, the blue one is a bit more correct. But both works, right? Okay, good. So the first person has risen. Okay. Pull up. Pull up bad or something. How do you end a PHP file? How do you end it? So I've never mentioned this to you at all if you notice. I've never mentioned this to you before, right? Did I? Okay, so yes, there's two answer. There's no need to and there's a question mark and dollar sign. Question mark in an angular bracket. This is the way. The blue one is not correct. That was a trick answer, I guess. That trick people. So you don't actually need to end a PHP file. But if you want to, you can, I guess. You want to end a certain part of a PHP and then input HTML data. You can use this. So next. Wow, a lot to over. Oh, 404 is making a comeback. Right. So what is the default type of a PHP variable, right? Integer, string, juggling. There's no default. It needs to be defined. Integer. I suspect this is correct, right? So juggling, right? I think I need to kill myself right now. Okay, so I think I didn't go through this deep enough, I guess. So by default, the PHP is it will take whatever you pass it in and then it will change and morph to whatever it needs, right? So it's a juggling variable type. It juggles around. There's no need to convert from an integer to a string. There's no need to do manual conversion. It's a wiggly type language, right? So it's juggling. So this tree is wrong, right? And not, right? Did the first person get it correct? I think, maybe? Which of the following is a logic statement. Okay, this is a relatively big question, actually. All of you will get it right if you answer I'm serious. Okay, so yes. All of them are logic statement. No points for this question, actually. Just testing ya, you know. Just testing. Which would output a variable value? What is the answer, actually? Oh, okay. Okay, good. Majority of you got it, right? So as I've mentioned before, if you use a double code, you can actually use the variable right into it. And when you use a single code, you can't throw in the variable. You must put it like that, then concatenate it with a top, right? Okay, good. So we've got KF still leaving the top. 17. What logic operator should we use to result in a false? Minimani, minimo, and just choose the answer. Oh, not bad. So, single equal sign is a set. So you set the variable. A double equal sign is a loose comparison. A triple equal sign is a straight comparison. When you have straight and an integer, this would result in a false. So it's a third one. And the fourth one, it doesn't exist, right? There's no four equal sign. It doesn't exist, right? So, I think we're almost close to our last. Which of the following will result in an infinite loop? Okay, so... Oh, this is so obvious. Why did I put it in? This is so obvious, right? Okay, maybe it's not that obvious. So, this is a... The first one is a standard four loop that will run five times. The second one is a four-each loop that will run zero times because items is empty. The wild false will not run because it's false. The wild true will run infinitely because it's true. So, as long as the condition is true, the conditional statement there is true, and it will keep running. So, for the four loop, right, it's the dollar sign i smaller than five. That's the conditional loop, a conditional statement for a four. Then the items, right, the conditional is, as long as there's still an item inside the items array. The wild false, right, the wild loop has a conditional statement which is just this single conditional statement that evaluates true or false. So, question number 19, 19. Okay, this is very simple, right? You got only two answers, right? I don't think it's that hard, right? Okay, majority of you got it right. So, but some of you still got it wrong so I have to say what is get and when false again. So, a get request is the standard normal request that will have the parameters in the URL itself, right? Whereas, false, the parameters will not be in the URL. So, false is more suitable for submitting sensitive forms like your username and password. So, I'm really glad that all of you got it. Most of you got it right. That's good. So, drumroll. And we got KF, obviously. Push KF, right? Hai, hai. Ya, you're number one. So, we got Pula and Pula. That's a very cute name. And Jun Xian. Okay, good. So, three of you, you can come now to collect at the end, I guess. We've got some shirts for you. Ya. Okay, so, that's it for the quiz. Ya. That's good. So, I hope you guys had fun, right? Let's just close this thing. So, we're on to something this time. So, we've done a rig in that retap and explain and clear your queries of any particular query. So, just in case for those who didn't come just now. So, I just want to show you this. So, again, the Wi-Fi SSID is NINJA. Password for the Wi-Fi is password, right? If you are shy and don't feel like raising up your hand, you can ask questions on rfm, right? So, rf... Oh, rf.fm slash my full name. Ya. So, ya. Ask any questions if you have. Okay. So, for those who didn't get the biggest workshop just a bit bitly URL Open this up. I don't feel it's just L or I. I think this looks like an L to me. So, ya, it's an L. Look at this. This is parallel. So, copy this and then paste it in your URL. Open up a Google Doc and inside the Google Doc you'll find Marvels or PHB and HTML Yes, we're going to do the setup again. Reset up everything again from scratch and show you what it's like to be using a painful platform called CodeAnywhere. So, open up your CodeAnywhere. I'm going to briefly show you. Okay, so there might be some issues with y'all. For those people it might have experienced some issues with CodeAnywhere. So, we have to recreate everything and also for the benefit for those who never came before we will do a very quick run-down of how it's going to look like. So, I'm going to open up CodeAnywhere.com If you have not registered an account there, please register an account. So, I'm going to destroy the container that I have for iq. So, we've got the codes down here that you can copy and paste like a genius and genius that you are. Alright. I feel lazy already. So, should I delete anyone here who never came here before? Raise your hand. Okay, good. I'll just destroy everything. Like an evil person I am. So, I'm going to how do I destroy this? Alright.   Yes, go to your dashboard and you see a default project in your dashboard. So, CodeAnywhere.com slash dashboard. There will be a default project. Oh, wait. But no, you can't delete it. See, when I try to delete it, I don't think I can. Are you kidding? So, create create a project create a new project then delete the default one you have. Okay, so create a new project in the dashboard and then delete the default one. Yes.  Destroy it So, it's very evil to destroy it. So, once you come to this page at this page, something like that Okay. Just give me a moment, right? So, now we have the new project and we're going to right click right click New Connection You see this new connection? Click onto it and I have to decrease my screen size because reasons Right, so search the stack here TH It's not right and then you see this thing here I'm not sure you can see it Yeah, so, it's THB then this thing then send OS 6.5 Click onto that click on that thing then name it Give your container a name Something like a recreated name like John Cena and then press create So, it will say create container Oh, I'm creating a container So, if you are experiencing issues with your previous container Try to put it up When you put it up it doesn't boot up and you're still having some issues destroy it and then recreate Yes So, Yeah So, right now it's deploying the container We are having so much fun Right Are you seriously kidding me right now Okay, there we go Great, fantastic We've got the container up and running and this thing over here will open up and you see this thing and you see this URL down here you see this URL, it's tiny it's a URL Okay, you have it on your container as well Click onto your one Don't copy mine, click onto your one Then you should see something like that Click onto your URL, you should see something like that You'll see something like that Great, fantastic So, we've got things running already So, right now we're going to do what we did before which is start doing the copy and paste So, the first one we have is index.html So, you see the the line-line-diny-diny connection thing Right click here, create a new file Name it index Ah, I don't even know how to spell index.html Make sure it's everything small letter, everything is in lower case index.html Press okay, then open up the file then go here begin your journey Being a genius engineer of knowing how to copy and paste Right I can't even copy and paste So, I'm trying to copy and paste Ah Really? See, I'm not a master at copying and pasting So, I pasted here and then I scroll down some more and then I pasted the tedious day This gets me tired Ah Shags Wah, are you kidding me?  Yes, I am We Ya Okay, good Copy index.html Press ctrl s Once you've done that You may proceed to copying the second part This is really tiring Okay, so Create a new folder Assets Name it Assets Then create a new folder within Assets Name it Yes Okay, boss Then create a new file Name it style.css Try not to go out of style Aha So, down here we're going to begin copying and pasting again Okay Copy Paste Oh, that's it Okay And remember to save it again Create this new file In the root directory Create Name it login.html Okay, so I think I can smell the food outside but it's still being prepared Can you smell it too? I feel like I'm talking to myself all the time Right So copy Paste Right Wow I should apply for masters in copying and pasting Right And then create Create another file Name In the root directory Create file Login.php And then Of course Of course, we're going to do something genius Which is Copy and pasting Can I copy As you can see Copy and pasting takes skills Not everyone can master it I managed to copy this and pasted Control S So just to check whether it works Refresh this page We should get something like that But we don't have a picture here yet Because we didn't have a picture So if you want to have a picture You can go back here Under Assets Create a new folder Called IMD Image And then put in your Image file You can go to index.html And you see this thing here Assets Image Azotic Shot Headcat So whatever you upload into this folder The IMD Should Should have this name Or you can change the name here To whatever you want So now we've done copy and pasting We feel like Pros already Has everyone mastered the skill Copy and pasting Ya Ya That's the URL You should see a Oh it's a capital letter I I must be Okay So everything good Okay So previously We've talked about logging in And things like that Try to log into Doing stuff Achieve The new paradigm Of being able to log in By defining our user login Information in an array We've achieved that And we're on our way To becoming geniuses But the question is How do we identify a user We got the login system But then we can't always Ask the user to log in Right There must be a way to persist The user Or something Does anyone know how How we can do this Anyone No one Okay So We're going to introduce this new topic Right here Brand new topic fresh out of oven Really hot right here It's the Not the latest coolest technology But it's the hottest right now Inspector So PHP sessions Is about being able to store And unique session ID Or the client browser So client can be a browser Right So it can be done in two ways It can be stored as a cookie Or be appended To the URL Or you can come to visit a page The page will have some URL parameters On top That will be the Unique session ID Or the unique session ID Will be saved as a cookie On the browser And on the server side It does some magic So how You can identify a user By storing it By storing some sort of data By storing the session ID Onto the user But how does the server Knows That this session ID Is belonging to this particular Session stuff How does it know Well, it has to store That thing somewhere And of course it stores it somewhere And this somewhere We call it On the server That's a session file So on the server itself In a temporary directory It will be saved as a Session file And inside the session file Will be the session Data So in that way The server will know What this client Represent on the server It's unique So If we take a look At php.ini And under session How do we know Where it's being saved So there's this thing So the save handler Is false So it's being saved as a file And there's no save path Being specified So by default it goes into a 10 directory So it's just a slash Right So that's where the session Lives Within the server And For the user, browser Cookies or the URL So the session Also Remember you'll get and post As the super Super global variable Well, for session We've got a super global variable as well Notice how I say super global variable Superman Yes, it's something like a superman Right But it isn't So So the question is How to session So We're going to do some Really simple Piping down here Which is really simple So let's take a look We've got our standard Angular PHP Decoration To tell the entire world Hey We're going to start writing PHP code And then we're going to use this thing Session underscore start So what session underscore Starts means that It's going to start the sessions So obvious So when it starts the session There'll be session Information available Session global variable Will be available for manipulation For getting information And setting information as well So you could possibly do something like that With the super global variable So something like this Dollar sign underscore session Square bracket Because it's an array Just like the super global variable Of post and get So remember your super global variable Get and post Well So for this It's also an array So we're just setting it this time We're setting user Equals John Cena So whoever visits that particular page Right now Would have the session User John Cena The people who doesn't Wouldn't have this session So it's unique To every It's unique To every single person To whoever Brows it So you have the session ID Or the particular browser So this session information Is then stored And assigned to that particular session ID So let's say We've got one person That visits this website In this website Only the first person Would have this data The second person wouldn't have it Got it Sort of No, maybe I don't know Thumbs up No It doesn't look like Oh, you got it I don't think a lot Let me just try to explain it again So Let's say This is a single In a PHP page And we've got John And we've got Mary John visits this Particular PHP page That has this code down here John Would have this Session It'll be stored I don't understand what I mean by this Later on But we'll progress from here first Okay So another thing That you all have to take note is that Haters must be sent Before body So what do I mean by this What is this even In HTML We've got hater as well But don't confuse that with this In Any standard And things like that You've got haters In your request Whether it's a post or a get Or it can be cookie information And this is the thing that we want So a cookie That is stored on the user Is actually Called the haters And as Any preprocessing Language Haters must be sent Before any other content The browser must be able to know What are the possible information Available before it renders the content So Let's really take a look So you'll get an error from this We're actually sending the body Before Sending the haters So we'll get an error from this Really simple example Body is the hollow world And the haters is down here Right So that's it So proper way of doing it You have to get your haters sent First Then your body Simple Great So this is where you'll see the magic happen Right If let's say John visits This page It will say Hey John Cena Whereas if Mary Doesn't visit this page And it says Hey Session user It won't say anything Because it's never defined For Mary It was only defined for John Who visited this particular webpage So as you can see The magic happening here It's really individualistic And applies to Single users and everything Because of the way cookies are being stored On the user itself Browsers So if let's say John was to clear his cookies He would see Hey nothing It would be just blank So John better not clear his cookies Or else We wouldn't know who is he anymore After he clear his cookies Because that's the only way We can identify the user Through using cookies But this This is the way we are teaching Down here So let's Give a funny joke To sort of Make it more funny John Cena Has a girlfriend Anyone of you know John Cena John Cena Is a famous WWE wrestler I think So He faces this issue with his girlfriend All the time So his girlfriend ask When can I see you And that was the ultimate dilemma For John Cena That was it He don't know how to reply her Because well If you don't get it You can't see me So yeah So I hope you cringe So this is the second part To using session itself So Down here We are introducing this thing called set And we are using the inverse The estimation mark To inverse The true and false So if The session is not set The session user Is not set Then we will set it If it's really set We won't go and set it anymore This is using an ESAP Function So we are just really introducing to you This ESAP Function It's pretty explanatory Of ESAP Like So And we just now sort of Lock Lock him in But we didn't know How we lock him out How to lock the user out So to lock the user out You need to do session start again And do unset Session user So it's basically unsetting this Session Ray detail Particularly to this user So the detail The variable will be unset Will basically be Reverse of setting So when you set It's using an equal sign So when you unset something It's using unset function Simple, clear Not clear So let me just explain Equal sign to set A variable Then if you want to Unset it Remove any value in it Just Completely throw away the value Inside of this particular variable You just This function called unset So it unset The particular variable So down here You got the super global variable Session We are inspecting into this array Particularly to the user So that's really How to lock the user out So Before we get any further Into more complex stuff We can have our lunch break Pizzas is outside Let's be back here Let's say around 12.45 Good So until 12.50 The food is outside At the lunch area It's at the piano If you don't know where it is You can Follow us and we'll bring you there Okay Okay Please leave the room Because we need to lock the room up Just for security Because all your laptops And you can't lock Just for security Because all your laptops and belongings So please bring out your water and phones Just ya Are you teaching me something very important? No, it's okay No, I don't know When to tell you It's fine I think they look very confused Everyone look very confused Okay Okay For this thing, it's easy to arrange I mean like Okay, so this is a Variable Okay, so inside this array Previously in this slide We have defined this thing So we have defined this array Then we are Setting the array Key We are looking at the array key of user Which is probably not defined And it isn't It's not defined yet So we are looking into this key We are just looking into this key And then we are setting Set to value Set to John Cena And then this function We can check Yes, this is set It's just checking whether This value here This super global variable Array And this particular key Within this array It has a value And it's part of the array So this is the key Yes, it's inside the array So in an array, you have a key and a value So this is the key And this is the value But how many values can the key store Okay, so It can Okay For integers, it's up to 32 bit For strings, it can be As As your memory can support So if you put A long string And you run out of memory How many can you store Oh, you can store You can even store Inside another array You can store an array In finality Okay, thanks Hello I think I'm going to ask I don't have a question There's no secret question And we aren't informed with questions Is it HTML or CSS? Okay, so You've got HTML, CSS And javascript on the front end Okay, so this kind of thing Is enough to do a website Actually, just HTML alone Is enough to do a site Without anything on it So CSS styles it And then makes it look nicer Then javascript adds the interactivity there Then these These three components would suffice For a website But let's say you want to do something more dynamic You want to customize content for the user You want to be able to lock the user in Register the user and things like that You need some dynamic Things, right? Because HTML, CSS and javascript, they are static They can't be changed On the fly So you need A server-side-up language Like, probably PHP To be able to do some Magic and then do Whatever it needs to Output dynamic data So these data are all dynamic And can be changed To whatever you want it to Playing with a variable inside A coding thing, right? Ya, so this is the Server-side-up programming Start Which is PHP Well, like you go a website You see the website is always the same thing But for stuff like Facebook Or automatic updates, every time you visit a page That's more of something, the idea is PHP Then those websites that display information It's more of the idea of HTML and CSS Which is static app Which don't change over time To physically change it, you have to change the code Rather than just editing the server-side Ya, something like that It's not the proper extension but There's more like, why, the way I see it No, it makes it clear So it helps So just now we covered a little bit On the sessions part of PHP And how we store Cookies and stuff On the client browser Ya Hold on So we covered a bit of sessions And how it's stored on the client-side And on the server-side So on the client-side, you have the cookies Server, you have the session files And things like that So no problem with that Things are going quite well so far So we've looked through How we have to begin the session By using the session underscore start function To tell the PHP That hey, we're going to start Having some sessions And start doing some sessions here And then Then you can do some session start So like setting sessions For the user and things like that So if you don't do the session start You would not have any session data So here Just now we previously Covered a little bit on the ESAP function Which checks whether A particular variable has a value So if the value is being set In the variable It will return a true If there's no value, it will return a false Then we Revisit the exclamation mark Which is the inverse operation Of a true false So if the output is a true And you put an exclamation mark there It becomes a false If the output is a false And you put an exclamation mark there It becomes a true And we cover a little on the logging out Which is basically just Removing the session data For the user So We've talked about how sessions Work and things like that But we don't really know how to put it in practice So we need to know How we can integrate The sessions into our login system So currently we have The login For our login.php You will have this Amazing file down here Which says Which starts this So Just Once you log in It basically just prints You're logged in And once You are Log in incorrectly It will just say You've been logged in incorrectly That's really So We want to store For the user To identify the user So what do we do So simply We go up here And then we type Session start So we begin the processing of sessions Using Our function code Session start Simple And then we start to wonder Where do we set this When should we Be setting The session Anyone knows When should we be setting a session Session data When do we do it In the login.php So we want to set The session When We successfully log in So only when the user logs in Then we want to set Session username Is this particular username That's really it So let's take a look At our if-else statements Let's look at our for each And then our if-else statement Which analyzes Our code here So here we can see We've successfully logged in We've successfully logged in So this is the part where we can Type in our session declaration So let's type in some code To so-called declare The username for the user So down here If let's say The first user is Fabian tries to login And then log in it's correctly Then we get Session our super global variable Which is an array And then we set The key of the array User Equals username So actually what this looks like As an array Will look something like this So the session As you remember When we declare arrays We use the square bracket Don't type in this code I'm just showing you So So as with any array In PHP You got a key and you got a value So down here you have the key user Pointing to the value of username So this is what What is inside this session So for more information about How this on session itself You should do a bar down Which we previously talked about In debugging PHP A function Bar down So something like this So let's actually Try this thing out And go to our login The html Down here Type in let's say Two users So I'm going to try login So we want to bar down That thing So this is the bar down result Array One result Where user This is just a Really just an array And that's really it Nothing really too special Just that it's a super global variable Don't worry about it So now that we've successfully Assigned The session Session User equals username We now know that This particular user is this Right So let's do some I'm just going to show you What do I mean by that I'm going to create a test file So you can follow along if you want to So right now I create this file Test.php And I'm going to type in some code So let's say I've logged in successfully So when I go to test.php I'll say this Welcome my username Right Simple So let's When I log out I will then lose that data So let's see what happen when I log out So session start And then we do this We unset the session We can just unset the entire thing And then we lose everything in the array And see what happen Refresh the page Nothing to show up And then We go and do this again Are you kidding me Let's save it Okay, let's try it Unset So now it has a problem With saving So now it Should be unset Right So Wow Okay Ah, there we go So now it's unset It's been unset So now it says Welcome Welcome blank That's the definition Of logging the user out So just now you saw That I've successfully logged the user out And when I refresh the page Or come thing There's absolutely nothing there Okay So you can see that Across different pages Just now I was on the login.php page And when I go to test.php We still had that session data There Because we didn't log the user out So it's able to operate Across pages Because the session ID is being saved For the user's client browser And on the server side You have the session file With all the data stored So that's what happened When you When you use Sessions Okay So we've seen Like how we log in The user successfully just now And then we store the username Just now And that's what we want to achieve So You might be wondering What's so good about this Ability of being able to What's so good about this ability To To even To even be able to log in And have sessions and things like that So if you see any E-commerce store It's able to achieve one thing Which is being able to Log in First You have session You identify who the person is And you really Customize the user experience So let's say This person has The name there Has a username So instead of saying Welcome guest Or welcome deal shopper We can say something like Welcome Fabian There's a more Customize user experience For the particular user And makes it a lot better For the user itself So personalize And customize So We've done integrating sessions In the login system Really simple, just two lines Of code down here So I'm going to show you again This line here This is called start So I don't want to copy and paste this Directly now I'm going to copy and paste it Later at the end of session Because I want you all to try to type a code So that you will be able to Remember better So let's just continue So now we have handed login What about registration We've got this We've got this array of data Right We can't be modifying this data Whenever someone wants to register Because it's just hard coded data It's just really hard coded array data Down here You have to change it manually And open up the file and things like that It's painful to do that So well We've got A solution to that That was taught out many, many years ago Not by me But by someone else We call it database So So what is this database So Essentially it's Just a server That's able to store persistent data It's able to store data That's it In a well formatted way Of tables With rows and columns So I'm going to visually How it's going to look like Ya With The ability of storing persistent data And it also Gives us a better ability to Do read and write We have this array down here We can read it no issues But if we want to write it We have to change the file That's not a very convenient way of doing things We can't be handling 100 users Manual registration So For now We're going to focus On this particular topic Of relational databases There's different kind of databases out there In my heart Like the NoSQL databases And What else there Like Relation based database Which is a bit different from relational database Which is based on true relations Of databases out there I don't know for you But on this topic itself We're going to focus on relational databases So things like MySQL, MaraDB Postgres SQL OracleDB Which is RDBMS Relational databases Can be short form into RDBMS Relational database management system RDBMS So It's table based format For relational database We have columns and tuples And tuples are basically your roles It's just a nice way of cleaning So something like that So you have a table down here Do you see a table? For the first one I can't see this So we've got a username We've got this column down here It's the username And we've got another column down here Which is the password If you look back to our array itself We've got something similar We've got username Equals pointy arrow Whatever So now here in the databases We've got something similar to that So each role Or each tuple We have here It's a new record of data One new user So from here We can obviously tell that The password of John Cena is You can't see this And as for Taylor Swift The password is I love Tay-Tay 1.0.3 So we've got this too Very, very simple But just a minute So we've got Data down here We can Somewhat search For data and things like that But How do we index things? How do we know this is the first one? How do we know this is the second one? Alphabetically? No, we can't So we have this thing Called indexing That we need to do In our database So Very simple indexing Which is true ID So For the first one We'll give it an ID of 1 For the second user We'll give her An ID of 2 So Probably when the user registration Was done John Cena registered first Followed by Taylor Swift But it's incremental You know how it's being increased So 1, 2, 3 Stuff like that We're going to run some Terminal commands So right here Down here If you write this thing There's this thing called SSH Terminal You see this?   Everyone got here, right? So right now You're going to do the most simple thing ever Copy the entire line Here Yes, the entire thing Copy And then Just paste that in You should see this thing Say query okay Zero rows affected Here, something like that Query okay Query okay? Or good So remember Copy everything from 3 database MyCommerce To this last semicolon Right, remember the semicolon is very important Is to signify Is the end of the MySQL command So right now I'm done here I'm done creating the database To table down there So I'm going to exit this By typing Asset I'm just going to type exit MySQL Everyone got it? Or good Raise up your hand if you have any issues Okay So I'm going to close this terminal And you should too Because you don't really need it now Actually We run the terminal command Which was a really simple command Let's go through this I'm just going to drop some water Don't switch things a lot I don't really wish me on So I'll briefly explain What we've just run Because We want to understand what we run Not just blindly copy and paste So So we're actually Diving into a new New world again We're diving into this strange world Of SQL commands This really, really fascinating world With this really, really fascinating Command lines That You don't really know And you should start knowing So I'm going to explain really quickly What we're trying to write here in terminal commands So at first line, we're going to call to MySQL Which is a database That we've early on mentioned So MySQL is pre-installed in your container And you can run You can bring up this terminal By typing in MySQL But in order to bring up MySQL terminal You need to log in to MySQL So by default, you've got this user root So Here we specify the user as root Dash U represents user Root Is the username of course Then By default You're Not secure Container You need to specify any password And we're able to log in To the terminal For the MySQL terminal Oracle Then we proceed To running some Constraint strange commands So the first command that we ran was Create Database, MyCommerce So what this does Is it creates a database With the name MyCommerce Then We proceed to Use MyCommerce Which means To tell the terminal Let's go look Inside this database Name MyCommerce Because in a single MySQL server You can have multiple databases So right now We've created a database Of MyCommerce And when we say use MyCommerce We're looking into this Database named MyCommerce And then After we look inside We're now inside MyCommerce database We run This command To create a table So it's Exactly what we did just now It was exactly the same thing You saw all this This was what exactly We created a skeleton So without this Of course There wasn't any data input It was just a structure So we created a structure ID Int 10 Unsigned It's an unsigned integer Which means There's no negative value There will be no negative value There will be 1, 2, 3, 4, 5 Of course Of course We don't need any negative value We don't need any negative value So we're going to make it unsigned So that we'll be able to utilize More white space For bigger numbers Then we down here we say Not now So not now means that Remember the now that we previously mentioned In PHP variables Now and void In this Column Any value that goes inside Must be a value It must not be now It must not be left empty Then Also increment Every time We insert a new record The number The ID will automatically increase By 1 Automatically increments by 1 So when we Just passing username and password The ID will be set for us We don't need to handle the ID setting Right And then we got username For our child 64 Which is 64 characters Variable characters Of 64 and not now So we are expecting The username to be specified Same goes for the password And we set the primary key Untuk ID So this is our primary key That identifies uniquely The data that we have Right And then this is not really important I think in ODP are not that much The character set Do you remember in HTML We talked about character set UTF, ASIC And all So down here we are setting the character set To UTF-A That You see even different Languages So now we are done Explaining the boring parts Of the terminal commands That is really dry and boring Let's move on to What Database really is So I'm gonna There's gonna be an incoming tool So try to laugh if you can Languages can communicate with the database So Languages such as Ruby And this thing here Do you know what is this? So This is a Python Ha, I don't know Okay, never mind So Okay, so Different kind of languages can communicate With the same database And things like that We're the same exact database So we got Ruby And you have the Rails framework And you can still communicate With the same database Which is MySQL You've got Python And probably have some Django For your web You're still communicating with the same web Database Still the same select Insert and create So Now that we've done The really basics of database We're gonna move forward To what we call Data Objects So Data Objects, wait a minute What is this Objects even We've never mentioned this Objects thing before Not even in PHP Part 1 Okay, so Well, it's a variable type So You had your integers You had your strings You had your floats So We're welcoming Your latest addition To your collection of variables We have Objects It's a It's a really brilliant thing To have We're gonna What we can do with Objects So We're not going to go into Object-oriented programming Because that would be a whole new topic By itself already We're only gonna Look at Very simple things That any layman could understand So We do what we call An instantiation of an Object So Sump It was NewSump Isn't it Ya, right It doesn't look Right No, it's not right This is what happens when you code In midnight Right So I think this is Wrong B No, this is JLC Okay, let's look at the documentation Right So When it's down, we'll use PHP documentation PHP.net We can refer to the documentation So we're not going to Go into The classes itself We're just gonna What was I trying to do Ya, I was wrong So I don't want it to look odd So Down here We've got some What am I doing Okay, so down here We've got some instantiation Of the Object itself We can see down here We said NewSumpObject So this SumpObject We just need to know That it's a class That exists And it's Somewhere that we have linked to Right And to get a copy Of that particular class We want to copy the entire class And put it into as an object We do this New Whatever class Which is the SumpObject NewObject So this process is called Object instantiation Okay, not to worry if you don't Don't really understand what I'm trying to do here Even what is this crazy guy talking about So later on We'll be typing some quotes I'll be showing some quotes Which will make more sense We'll dive more into the PHP DataObjects So why do we even have DataObjects In the first place is that We just don't have We have the database But you don't want to talk to the database And extract data out We need to use what we call SQL commands We need to write SQL commands To talk to this database That we have So PHP DataObjects It's a layer That help us interface With the database It's a layer that help us interface That simple So the thing about it Is that it's based on objects So we just need to know How objects instantiation work We're not going to go into details This is how it looks like Try to feel it Like how it looks like It's really just like any other Array, declaration, and things like that Except we got a new And then the class name Let's take a look at PHP PHP DataObject code So don't be scared by this We're going to look at this So down here We're actually doing What we call an instantiation $dbh equals New PDO There's a space here by the way Open parenthesis What is this Single code MySQL Which is the database that we have $host Equals localhost So the host right here Is where is the database The database Must have an IP address Or it could be the same server itself So we can point towards The same server which is localhost Followed by the database name That we have given just now What was the database name that we have given just now MyCommerce So that was the database name We gave it just now Finally Followed by the username Which was root And the password Which is blank So down here We have instantiated a database connection A PDO A PHP DataObject I'm going to pronounce it Is it PDO? Ya PHP DataObject It sounds better So PDO In object here Connection It's a connection to the MySQL database That is located On the same localhost So what we are doing is that But doing exactly what we have done just now Just now We went to do this We went to do this We went to open up terminal And we went to type in MySQL Dash U Dash Root And we open up this After that We went to switch to the database Which was use MyCommerce So what it did What this part did Was really just this So when it instantiated The new connection It was doing this It was doing exactly this Really, really that simple So But it's just that The code has been transformed into a PHP format So that we can do We can do more things In PHP instead So Do you understand This first part? Okay So what we really have here Is a connection object We have a connection object And once we have a connection We can do something We have that connection We have a link Between Our PHP and our database We have established a strong link An authenticated link That is there So next thing we want to do Is We want to do some coding To the database So this is when we try to Check whether we have This is when we try to Check the database For the user and the password So let's take a look at a second statement Now here STMT equals DBH So as you can see Here And We put this arrow We put this dash And an arrow there So it's something It looks familiar to the array Which we had the equal sign Then a pointy arrow So in here We are calling Towards the function That exist within the object So the object That we printed just now Does have a function Within itself So objects are a bit weird You can have functions Within objects So unlike different Unlike arrays Where you can't have Actually Possibly code in the new Okay, so let me give a better example So unlike integers You can't have a function Within it You can't have that So Whereas for objects, you can And we are actually calling The function Just like what we have previously done So echo And all that, there are all functions that are pre-built Whereas This function is pre-built Into that object itself So we call to prepare So we are doing some preparation here We're going to cook something We're going to cook the next Gordon Ramsay dish That will burn the entire world So we select Astrid What is this astrid here So this astrid here It's very commonly found in programming languages We signify A wildcard And then what is a wildcard Well, a wildcard It means everything It means that We are grabbing every single thing So what is We are grabbing every single thing From users So what is this within users What do we have just now What is this within users Okay So what is this within the user's table We got 3 data that Is this within the user's table The ID The username So when we reduce the wildcard It selects all these 3 So that we don't have manual typing ID, username, password So we don't have to do all that manual So the wildcard done that For us Okay So now Now that We selected ID username and password From users We're going to do a conditional check Right In PHP, we got equals equals Checking Something like that We've got comparison and things So in SQL We've also got comparison We've got this thing called where Where something equals to something So This is not setting So in PHP A single equals sign sets the value But in SQL A single equals sign Is a comparison check Boom Mind blown So We are checking The username Is a question mark And The password Must be a question mark What is this question mark thing here Right But wait We want to focus We just want to focus on the conditional That has been explicitly stated Which is Where the username Must be something And the password must be something So we previously written some code Down here Login.php So it's essentially doing this It's really just doing this It's really just doing this That's really what it's doing And the end Instead of double Double ampersand Instead of double ampersand We have a normal End word down there Right So Now we've identified the conditional Check that we had And the data that we want to retrieve From the query itself So it was a select statement Selecting data From users Where Username equals to some particular username And the password must be That some particular password Right, next Down here we have this username Equals LL Password equals very secure password Obviously that's not very secure So We prepare Vegetables and meat And things What's the next thing to do We want to Start cooking To start cooking We need to execute the statement Of course So down here We execute the statement So if you see And observe carefully You will see That the question mark here Maps to this thing And this question mark Maps There's something wrong I'm just going to quickly fix this Okay So I forgot Anyway You can see That the username Maps to this Maps to this First value of the array Maps to the second value Of the array You'll see It's really just it So What can't we just put The bloody thing into Here immediately Right, we could do that Right We could But do you remember the first time When I talked about how We could do something Brown naked And burning people Or something like that We could But we shouldn't So same goes for this What we are trying to do here Is we are trying to prepare And execute The benefit of this Is that it prevents what we call a sequel injection So we will make Statement preparations And then we execute it like that It prevents The security vulnerability Or actually it's not a security vulnerability But it's Exploit a simple sequel injection Right It's really just an injection We want to prevent So malicious people Can actually drop tables And do lots of things And do plenty of evil things That we should be afraid of Right So if you want to prevent that from happening If you want to know more about What sequel ejections are even You can use This friend of ours Called Google, DuckDuckGo, Yahoo, Bey All of this To help you find out What are even sequel injections And what is it even So it's a really It's quite a topic to talk about In security itself So just keep to this code To protect you from Nasty stuff So As with the conservation Of problems So you know in physics Anyone here study physics Nobody here study physics Really? Okay In physics, you got the conservation Of energy When at the top of the hill You got full gravitational potential energy And at the bottom of the hill You got full kinetic energy So same goes for this You have the conservation of problems Right When you try to solve the sequel injection Here It kind of creates a problem Which makes things More complex But in life We always face trade-offs Right And of course as a human We know which is better Right Which is better Losing all your data And getting your entire site Compromise Or writing a bit more code Right, so that's an obvious trade-off That we want to choose If you choose the first The door is just there If you choose the second, good Stay here Okay, so that was What we did just now We Let's try to log in Like what we tried to do So just now we had to select Astrid from users When username equals something So now pretend That the user keep The username in the login form Taylor Swift And then the user who keep in the password Of iLoveTK123 So what's going to happen Well, it's going to look up the table It's going to look up the table of users Which is over here And then It's going to look at the first one Doesn't match, the username Is it Taylor Swift No, it's not So what should we do We move on Just like life We've got to move on So we move on And we found the username to be correct But wait What condition we must fulfill Our ultimate fulfillment Statement of password We look I love TK123 Is it the same? And we get this tuple down here So the winners goes to The row ID too Yay So we got our winner down here We selected this record down here Amazing record What winning record down here So We really just Selected it What we God was an Array We sort of get an array Of data that we selected So in this array We've only got one data One row If let's say There's another account That's exactly the username of Taylor Swift And the password is also the same You get 2 results You get an array of 2 results So right here, now We only get an array of 1 result Okay So How do you know I think I flesh out the answer A little bit So how do you know Let's say The login details was correct How do you know that We know that it's been selected Successfully Then what do we do next We want to count the number of Results we get So presenting to you The latest cutting technology Called count rows found Right So we got this Brand new technology down here Which allows us to count The number of rows Through the query That we have executed just now The select statement How many rows of results Didn't return us So obviously When there's no result When there's zero Obviously it's wrong details And If there's one result What does that mean Well If there's one result That's really basic common sense And really logical stuff We have there Any 3-year-old kid Will understand So We transfer that code That I've explained just now Into real PHP applicable code That can rock the entire whole Using this So just now we wrote Some statement And now We're going to count it And here Because in PHP When there's zero It's a false When it's a one Then it's a true Or it can be two So we got Some data We got some results So obviously the logging credentials Was correct So within this if Within this statement itself It represents The correct logging credentials That we must carry out So We can see here specifically We do this $stmt Arrow Arrow Which is the function Which exist within the object So I'm going to drink some more water Water tastes Good Like Clean water So So we want to know What happens When we filled When we filled our mission Do we try again So Let's see what happens When we give it a correct username And a wrong password So we get Basically zero roll counts Right Whereas When you have a correct You get You get one roll count So Let's briefly understand What our logging system is made out of so far So I briefly explain to you Like the select statement And the roll count So let's Do a really quick system summary Of how the login will run So first The user will submit The form data So you got the html Input username Password Password And of course After that You use your Super global variable The post friend To extract the results out PIDOS PHP Data object select We can run a SQL select statement And then We check for the number of rows We got from the result Right And then if there's a roll count Then we create the session When the user's ID If no, then give error of cost So that's basically what we have so far As discuss Of the login system by itself Pretty magical and pretty easy So let's do our integration Right now So we're going to start typing some We're going to modify Login.html Login.hp To suit Okay To be able to integrate Our PHP data objects Into the login system So we're going to mainly focus on login.html So open up your CodeAnywhere editor So right here Login.html We see that we've got these users Here We've got some users And of course We've got our for each load So we're going to remove this Right here We're going to remove this already Because we don't need it anymore Because all user Data is stored in the database So we no longer need a user To store our user data Right here We've got username Password, login, false Okay Now We're going to do PHP data objects We're going to try to Establish the connection first So let's go and Establish the connection Hold on So I'm going to type this in DB DB equals New PHP Data object Open parenthesis Database type Which is mySQL colon Hose Semi colon Database name MineCommerce Which was the database That we created just now Comer Space Single code R-O-O-T Single code Comer Single code Hose parenthesis Semi colon So this is Essentially Our statement That is able to instantiate A new PHP data object Connection So in DBH DBH is essentially Now a database Connection Object So now that we've achieved Our brand new achievement Brand new Instantiated PHP data object connection We're going to Begin to do our selection So let me go and Copy and paste So down here We've got $STMT Equals Page blah blah blah Let me just So STMT What the heck is that even? What is this $STMT Well It's a short form of statement So What this Statement is Is this thing here So this is actually what we call an STL statement Then we are preparing it We are Preparing the ingredients First And setting it to become the statement So this is the Ingredients I have been prepared As a variable statement So we are running a SQL Select Which is select Walkard From the user's table Where User name Equals question mark And password equals Question mark So you might be What the heck is this Do you see this This thing here So it's If you look at your keyboard Beside your one There's this Curly thingy And then when you click it When you press onto that thing It'll look like that So it's just run on your keyboard Beside one Yes You have one Beside one Do you see it? If not I suggest you to burn your keyboard And then sell it away On carousel For $500 So now that we've achieved something Remarkable Such as Finding that Weird, formal thingy that is floating Let's try to do something more By copying and pasting Won't stop it Right So Actually I'm going to just use square brackets So your username Is here Equals HTML entities Tada Password And then STM Statement SQL Began cooking With the username And password So username Will then be mapped into Into this first question mark we have Password Which is the second Second thing in the Second key value Is then mapped to this second question mark Right And then it executes the Prepare statement And then it starts The magical magic that happens To look up into the database Itself So if you were to manually do this In excel sheet or something You'll be You'll be facing a lot of problems Right So that will be a total pain in the ass Because of course Robots are more efficient than us Weakling humans Right So they're going to be Efficient things Because they're more efficient than humans But everyone got it here so far So everyone Understood very clearly how this Entire selection process Execution process Entire thing works Or good Okay great Fantastic So now that we have all Human weaklings Being able to understand Let's move on Right Let's move on to the part where we Do the row counting So down here I'm just going to copy this And then It's down here So down here we've got If Statement row count Right So it's obviously the correct Prudentials down here Right so What we're going to do Copy this Day Over here And we're going to paste it in here Right Wow So much easier And then we're going to delete This bunch of users Right So actually we can even Remote this We don't even need this anymore We can just put an L statement Down here And of course remember to hit The save button So what we did was We transferred our previous code Some parts of our previous code Into our new code Which was the part Which echoes out Actually this is wrong Let me give you a second We could do that So down here We're doing The setting and stuff So Really simple code Based on what we've learnt so far Which is the sessions And database Database, objects, and many more So Junhao Was mentioning to me I think it was just today That he mentioned to me That he has an electoral So I think he has an electoral That basically speaks In a very monotonous way And He even falls asleep While talking Because Because his voice was too monotonous So an epic An epic electoral That falls asleep to his own voice Monotonous voice So just imagine the class How it will look like If you probably have even Students Most of them sleeping already So now we have achieved Our basic road counting And stop and logging in And doing the sessions thingy I want done this All good Give a thumbs up or something I'll see a few Okay, good If you haven't Just raise your hand and stop We're going to move on To our second installment Of our login system So we've successfully Integrated database And PHP data objects into our login system Let's do our registration system Right So What was the difference even, right? Just now we were just Basically what we did just now Was that we select We read data from the database We're just reading data from the database But we're not writing New records So we need to do that We need to do this In our registration system So let's briefly discuss And think through how we're going to do this So it's Really similar to the login system Really, really similar Except we add data in the database Not just chat Right So So something like that Don't copy this code yet We're going to have time later So just read through this So we previously had We have the same thing Which is instantiating the database Of the database object The PHP data object Then after that Statement, prepare This time, instead of select Select extract from Use the table Where you've got to use the name and password Really, really similar Just the difference was It was insert into And then followed by A bracket Values It kind of Look like an emoji down here I think Just a very odd looking one So you know Even this have some Cute emoji or something So yeah In the spot error I made the same mistake down here But I really didn't have a close parenthesis So So let's think through how the registration system Will work Actually, let me try Okay, so registration system Down here Just We're going to do this Alright So registration system So the first thing is Well, of course the user summits The form data And then The PHP server Would then do a PHP data To check For assisting user name So we want to check it The user name has been taken We just want to do that And then we check If yes Then if error If no We do an insert So We don't want to have 2 Taylor Swift Down there And there will never be a 2 Taylor Swift So Of course we do a validation To check whether there's an existing user name Of such Before we register So now Really simple to what we've done just now Let's do this again So we're going to create 2 files Register.html And register.thp And for register.html We can copy most of the code So we're going to do that So let's start off with register.html First So right now I'm going to create the register.html file I drop the mark I'm going to copy everything here And I'm going to paste it Into register.html Right Then down here in the form action I'm just going to change it into register.thp And when I go up I'm going to change it into register Registration actually So in the title I changed from Login into registration Spellcheck anyone Is this correct? I suck At this kind of start So again After we change the title We go to form Form action equals register.html Change it to register.thp And of course change this From login to register as well And that's really What we want to change That's really it It needs to be changed Okay Ya That's about it Now Everyone made the changes Copy the code from login.html And then paste it into register.html Then Change the form Form action From login.thp to register.thp I believe that Everyone has changed the code For the register.html This part here So in register.html The form action Should now become like that And then of course Hit the save button Control S So now we've done this part Now we're going to create A new file Called register.html Can I click? Okay I hit Let's do What the login has done Right What is the login done It went to check for data So let's just copy everything First And then Paste it in here So down here Instead of checking for password Right We just need to check if the username Of the same has Of existence In the database So we don't need Password We don't need this So we can remove this So when there's a roll call The username Is taken If there's no roll call Then the username Isn't taken Simple Hmm Hmm So what I did just now Was I removed The end Password Equals question mark And then I removed the password From the statement execute Please retain These two things here Actually And then of course So Let's take a look at If else here So if there's a roll call It means that The username has been taken If it's else The username has not been taken So we can safely insert it into the database So the logic is there So we check Whether the username has been taken If it's taken We say Blah blah It's taken If not, then we insert And then we say So let's do that now So let's do our Prepare Right Hmm I'm just going to be very lazy And just like in STM So I'm going to type dbh Using the same connection We're going to prepare Prepare So I'm going to insert into Actually It can It can be Small letter as well For SQL, it's case insensitive For the Statement part But certain data It's Case insensitive So we want I be careful sometimes So users Where Oh, no no no I forgot username And something Yeah It's We're going to enter Don't need to hit enter I'm just doing it because It's more available in a single page So that I don't have to scroll that Right So I put a question mark there And another question mark Right So that's what we did Right There's the SQL statement Which I forgot Just going to scroll Little bit down And of course hit the save button It's always important To hit the same button Okay, all good Fantastic Not yet Okay, not yet In the meantime, while people type code Let's have another Lame joke down here Right, so as usual Lame jokes are always very healthy So Okay Okay So You know when you I've got this friend Who have this particular Liking of eating prawns With shells So When he eat the prawns There's shells on it, he likes the shell Because it tastes like a MRT store Yeah, and this particular MRT store Is quite well known We have even a Monument there And this particular MRT Stop is none other than Crunchy So the prawn Tastes crunchy Ha ha ha Okay, I see that not many people are typing already So I guess everyone is done So we've done this And Let's check out our code So I don't know if it actually works So let's go to login.html Let's go to login.html And let's try to log in first Because We don't have any details So it should tell us User name is incorrect So let's go to register.html And we have the registration page I'm going to register Something like My name With my password Okay, so don't told me That I've registered successfully I'm going to log in I'm going to type in My username with my password Oh, really? Oh my goodness Sick This is recorded So yeah, the password is not in So the Registration won't work Actually I should clear up Database first So if you actually Try what I tried just now Follow what I do and clear the database Okay, so Again Again, if you Did what just now Do this MySQL-U space root She enter Open up the MySQL monitor And then Type in useMyCommerce With a semicolon of course So now it switches into MyCommerce database And now I'm going to show some database First Oh, it's empty set Okay, good I didn't even register any data So we don't need to drop any data So let's go back Go to change your register Of PHP Under statement 2 There should be username Followed by Cormor, password Okay Okay, so once you've done that Save the file And then go to register.html And then register So I'm going to just try the database First So now So now I'm going to go to login I'm going to go to login.html And try to login And it's going to say Locked in as My username So we have successfully Implement A registration system That is connected to the database And the login system that is connected to the database as well And we were able to successfully register And of course Login So but Actually Ya But Just one last part Before we take a break So You will notice that In the database My password is stored as a password It's a plain text So anyone Who has access to the database Will be able to see my password Right It's stored as plain text And we don't want that to happen We don't want people to be able to see Our own password And And let's say Let's say If your database was to be compromised Your user's Passwords Will all be leaked out So We have here Okay In practice and modern systems nowadays People still do Store password in plain text Shocking but true Okay So we want to not do that We don't want to store our password in plain text And then Have people screaming at us You are needed So we don't want that happening So let's do what we call A hash How about before Okay A hash It's not the hash round you get from McDonald's But rather A really really good Way of a one way encryption So you might have heard of encryption before But with encryption You could decrypt it But for hashing It's one way Once you There's no turning back There's no U-turn There's no decrypting There's no way of retrieving Back the password There's no decryption So We're going to hash Our passwords So it's really simple We're going to use this thing Called the crack We look up into PHP It's something called crack And it It's said one way Right So I'm not sure If our version has that Yet This is 5.5 Give me a moment We don't have this We're using a decrypted An online product Actually 5.4 is an offline I think So we're going to use crack So crack Accept With a sort So Sort It's not the movie sort Neither It's the amount of sort you get from Play games like League of Legends Right So it's not a sort Sometimes you might get salty But it's really not a kind of sort So It's a way Of which It helps to It's the Algorithm that's being used To Do our hashing So we've got different kind of sort here We've got ND5 We've got blowfish We've got But we're going to use this thing So let's use Blowfish So So the first thing is String String Which is our password So we're going to specify Crack Blowfish So it looks something like that Do we have hash equals Yeah We don't have this either So We're going to just use crack And then like Yeah Okay We're going to use crack And let's implement it in register.php First So as you can see We've got our password here We don't need to turn into entities anymore Actually Do we We don't So we're going to run this We're going to change this hash gate now And this into crack And then we're going to put a comma here And we're going to put crack Blowfish So this is what we've done To our password So Has anyone seen a blowfish before? We've got some blowfish It looks bloated And it looks like a fish So Now that everyone Has implemented this In register.php Okay Let's go to login.php And then we do that as well So Go to login.php So what happened To our existing registration data And logging data Well They won't work anymore Because we've implemented it that way Right So what we should do now Is we should clear our database And get rid of the previous data That had passwords Stored in plain text So go to your MySQL And we're going to run Transit I think Trunket Trunket Trunket It's been quite sometimes Since I've worked with Raw SQL Actually So that's my excuse Anyway Trunket table So now we've implemented this crack Followed by comma Crack underscore blowfish Go to MySQL MySQL-U What It will open up Use MyCommerce So database has changed To MyCommerce Now run trunket table Users So when I now select I should have an intercept So now when Trunket Everyone trunket it I don't know how to spell it So it's T-R-U-N-C-A-T-E T for Thailand R for I don't know R for U for United Kingdom M for Netherlands C for Cat A for Apple T for table E for elephant Trunket table Users So first that MySQL-U Rood Then enter into MySQL monitor Then Run the command Use MyCommerce Semicolon Then run Trunket And that's it I can't really expand this Can I? So you no longer have to Screen your eyes To look at what I type So let me highlight the game This part Over here Follow by Trunket table users And that's it Trunket table And get rid of the users data That you created previously through register.php So now Let's Go back to 100% And We're going to go To our login We're going to go to register.html So go to register.html Register and account again And see what happens So it's say user registered successfully And then we run the select command We get this strange Thing here Your password Is no longer syn It can't be syn In the database table anymore And that's a good thing So Let's go to our login.html And see if anything else has changed Are we still going to login In the same credentials? Let's see So We were able to login With the same exact details No issues at all No problem Absolutely no problem In our table itself We still got our password In this With our blow fish So that's it That's really it for our login and register system So let's now take a break Of 15 minit I guess So 15 Class 35 Is 50 So we come back at 250, which is close to 3 250 Welcome back from the break That we had So So just now we've done Our login registration system That was really functional We even had a separate database For us to do our authentication And registration etc And the password is even stored In a non-plain text hash format That is really so revolutionary That Not a lot of people are doing it So it's not really that revolutionary But yeah So we've done our basic login And registration system We are not going to Go into much Details on how you're going to Further personalize the experience Y'all can figure that out yourself By having By changing your index.html And further Having a Session To print out the username And things like that But not to worry Not to worry at all Because We're not going to do that anymore We don't really have enough time For that anymore We don't really have much time For PHP anymore We're going to move forward Into our first world First class Golden Village JavaScript So When you think about JavaScript There's this Java in front But it's not Java So Let me just give Not a very funny story But just a few times That interesting experience That most of you might experience In the near future So I've been through several occasions Where Hiring managers So HR people So wow You know JavaScript You probably can It's systems Now it's like okay no Anyway So Javascript and Java It's very different languages Javascript is weekly type Just like PHP So javascript and PHP Does have a lot of things in common As said One So For javascript Actually Singletrader Wow Singletrader So it's not your grandmother's trading But more of the computer science Trads and things like that So You might have probably heard Of this thing called multi-trading Or singletrader Dingi So in programming languages There's also this You know Our CPU So probably my Krapi I3 down here has Probably 2 cores and 4 threads So there's 2 cores and 4 threads So PHP Would be able to fully utilize Every single thread I have On my computer It's able to fully utilize It's able to do that So no issues And When it's able to do that We have this specific term Multi-tread So PHP is a multi-treaded Language So it's a multi-treaded Interpreter scripting Language So if you want to put it more cheap as possible Whereas you have javascript Single-treaded Dar So when it's single-treaded There's a drawbacks And also Some good things about it Although It's not able to fully utilize Every single thread But Actually javascript has been improved a lot In some cases Our modern browser engines Such as V8 Which is built into Chrome We call it the V8 engine And for Microsoft It's called Chakra And for Mozilla Firefox We've got Web Monkey, I think So Javascript engines that run Underline our browsers That makes our lives more fulfilling everyday While we watch videos on YouTube's Of cats YouTube's website Websites like YouTube Facebook, Instagram And all To improve the user experience Of Whatever you have So Be very thankful that we have javascript So it's really here just to Add interactivity So you can't make a website Without javascript You can And you can also make a website Without PHP Of course, it will be static But PHP adds the dynamic Stuff into it And it makes it more dynamic And you really got a full-flash e-commerce store Somewhat like a full-flash e-commerce store Right With a login and register system Right So it works It's solid rock It works well But Have you seen How the login was like Do I need to show you how the login was like Well You have to hit submit button And then you get redirected to login or PHP And then Ya, you get logged in It looks like that So that was really basic Stuff We have there And it kind of lacks Right What if We could stay on the same page And then we hit login button And then it says Well, you're logged in Or it says Nah, you're wrong We can't log in with this credentials You have that So We can do that By staying on the same page Not even moving from one page to another So So You might also have seen Animations and things like that So some animations Dependent on Javascript Although You can do animations With What we call CSS3 And some A lot of things runs on Javascript too Even in the server side So So let's take a very basic example Of drop-down menu So you can see this drop-down menu It's highly pixelated Because I was lazy And I decided to just take a screenshot Like that So I took a screenshot Of this That we had on all your laptops So right now you have it And then with the power of Javascript We are able to Wow Such amazement So you will do this Drop-down Drop-down this action Another action Something else here Separated link That's Javascript So That's just one of the elements Which Javascript Add flavors to our lives So Where exactly Is All of this So How exactly do we add Javascript So in our first session We've got HTML So we look through about And CSS Of course it's actually the second one So the second one We talk about bootstrap So bootstrap relies on JQuery library Based on Java It's written in Javascript So You saw that we explicitly Place that particular script Tag at the bottom We place it at the bottom Why did we do that Well the answer is obvious And it's written on the screen But don't look at the screen Look at me Well When you load It load the page like that It reads From top to bottom Really simple That's how you would read So that's how robots would read So you are a robot Wait, you are not So When it loads the page and everything Oh CSS file I gotta fetch that CSS file Then when it goes and get the CSS file And It gets the CSS file Then come back to the HTML document That process is what we call Ion blocking So It's a computing term as well So what happens when it gets Ion block So the HTML document Will not load Until The style.css File gets fully loaded Once the style.css Is fully loaded It will continue loading down So imagine yourself Putting a jQuery file Putting a JavaScript file At the top Well, what would you get You'll get a lot of load time So the user will probably Like This page is loading really really Really slow So back to the essential of what I said just now You don't need JavaScript But It's nice to have So it's not the most important thing So Well, whereas for CSS You need to style everything So of course it needs to be on the top That's priority for it You need it to be at the top That's what CSS So even though it's Ion blocking We still put it at the top So JavaScript will place it at the bottom So when all content Has been fully loaded Then it will start loading The JavaScript files So the user will still get To see the content and everything And still be able to read and everything While The page still tries To load for the JavaScript files And execute whatever it needs to execute So That is why At the start We've chosen to put The JavaScript text At the bottom So that the JavaScript files Will be the last to be loaded So let's move on So this is how It will look like So if you scroll down your index.html You log in to html You'll see something like that Script Source equals Assets Things like that So right now At this Script To actually Actually Don't add this script Don't add this script Just note that this exists For now We'll do some typing later on So this is how it will look like So Now that we know How JavaScript functions With html and things like that And everything Let's talk about the syntax Of another language So we've learned Several languages so far Html Which is a document markup language CSS Which is a stylesheet language And we've got PHP Which is a more A more complex language And we have finally JavaScript But not to worry Because Now that you've really dropped onto The basic theory And concepts of programming itself Learning JavaScript Is not that hard And PHP and JavaScript Are syntactically similar In some sense Is syntactically similar In the basic forms On the most basic level Is very very syntactically similar So On the most basic level Well Instead of the dollar sign You use what we call VAR VAR Space Sum variable Equals hello world Alert Sum variable So right now I'm going to do a really quick Test.html file And in assets folder Create a folder Name JS And in In the JS Create What we call app.js Right So down here we open up Test.html first We're going to copy our standard html file document Now I've created Our basic test for html With html So let's take a look at how it looks So just print out like that Releasable So now I'm going to approach To app.js And then add in what I've type in just now So what did I do just now Well, I type in VAR Equals hello world Alert sub variable So let's do it Like that So alert So in PHP We've seen like how function Has a parenthesis there And then assets parameters And then for it to be called The point So far sum Variable equals hello world And then add with a semicolon as well You see it's really, really Quite similar in a lot of sense Here, semicolon Equals sign Bar So this is how the App.js looks like And this is how test.html looks like Thing is correct I'm just going to drink some water first We've done some pretty amazing Html document down here Which was what we've learnt a few weeks back And this probably Has refreshed our memory a little bit With some fresh html typing And some JavaScript typing So let's go to our html page And refresh our page And see what happens Hello world with an alert text box Pretty amazing with an okay button No other choice but to press the okay button Because that's life So that was what happened You saw that? Let me just refresh that Hello world Did everyone get this? This? Ya Not the MRT I thought you always got a Let me check I probably got a Say some of them Okay Nehma So everyone got this already Got the alert Amazing isn't it You know what's even more amazing All of these are all static files Right These are all static files There's no calling To an external server Right There's no PHP involved here No PHP magic involved here All done on the client side All done in your browser So it's Really incredible What your browser can do So Unfortunatly People misuse And then use it To send 1 million pop-ups And then it gets really annoying And ask you to subscribe To the million lives So we got some really basic Alert here That's really just basic We're not some basic people So let's make it more complicated Because we are complex Little human beings So we've declared the variable We've called upon a function Called alert So let's do integers So something like this So let's look at integers So far Your GP equals 4 Then alert Your GP It comes out 4 So I think most of your GP Okay never mind So other than that We got Standard Integers Strings And many many more So let's take a look at another example We have here Floats So You know I always Joke about With my friend Who Who is currently in year 3 as well She's my classmate And she has 4.0 Consektively for cumulative GPA So I was I always We always say She's going to graduate with a GPA of 4.1 Breaking the scale of 4.0 GPA Since she's always that studious So you got Your floats as well Standard floats 4.1 GPA And of course your arrays Look how similar they are To your PHP arrays 4 Floats Equals Square bracket Apple orange pair So And Apple a day Keeps The doctor away I think So if you happen to have a Lecturer Who is a professional Remember to bring an apple So that your professor wouldn't come To the lecturer I don't think anyone got it It was really lame So Let's move on To objects So Objects are a lot simpler In In Javascript And I think almost everything Is an object In Javascript It's a weird decision They have made upon Ekmascript itself So a lot of things are actually Objects And I'm not even sure if an array Is an array Or is it just an object Ya So I think even an array Is an object If I remember correctly So ya So this is how an object Looks like So Something like that You have a Kodi Bracket Name John Cena Helm Salak Salak Ok, this is a really lame one Ok, so There's this There's this gang Called the 369 Which people call by Salak In the Like Dalek Ya, so Ya Ha ha It's visible Course is not You can't see it And then alert When you alert it It will just simply say Object Let me show you What I mean by that So Let's refresh our page And then it will say Really? Did I do wrong? Oh I forgot I forgot a comma Did I forget anything else? Oh I hate this day So Google Docs tries to be smart And then like Change my Stuff into Whatever they think It should do I don't think this is Really correct Ya You get Like that You just get an object So I'm going to do What we call Stringify And then we'll see what happens When you get this Right So the JSON.Stringify What it does was It transform That object Into string format So now Now you can Absolutely read this Right And of course In objects It's It's always With Double quotes So what I did here was Not really right Where's my mouse? What I did here was Not really right But I don't really care So So that's how it looks like You look at the strings They are They are all having this Double quotes So which is Supposingly the More correctly Right So that's That's really it for Objects Just need to know this This This variable as this S In In JavaScript So our standard If else Bar sum variable Equals true If sum variable Then Alert hello Else Alert bye bye So this is our standard If else again Which we've sent earlier on In PHP So You wouldn't have any trouble remembering it So there's a bit of difference here In In what we call this JavaScript So if you see the else if Right You'll see that there's a space there The else Space If Okay this is because In In JavaScript There's no There's no logical Comparaton Name The else If Right So what What essentially is Start doing here It's just that Just creating an else statement And within the else statement itself You have an if So let me type out What it will look like Okay Okay this This JavaScript is Trying to be spark I mean this Google Docs So you see This thing It tries to be Just Google Docs Really Hold on So this Here It's the same As Writing this It's the same as writing this Alright So even in PHP itself It's also the same thing Right When the else if When else if is used It's Logical How it looks like It's actually Actually this code here Right But when we When we put Else If We make our code look Neat Actually Because there's lesser indentations needed And it's also pretty clear Cut to us Right So this is how The else Space if works Okay So if we run this We should get hola And there we go Right And we also got Four loops Four each loop And also Wild loops Same as What we have in In PHP itself Right So it's still the standard loops That we usually see And let's try to do something More Let's try to write some content Right So Write some text in the body Sounds easy Let's copy this code So What it's essentially doing here Is I'll just Screw this thing In PHP we Contacting it with a dot In JavaScript We can contact in it With a plus sign Right So it's just adding the string together Right So Some words So let's refresh the page And see what happens Really Okay So I don't think Oh Ya Document.write Ah, there we go It's not document.body But document.write So We've added some content In Document.write Some words So what we got was Was this We took this some words I love Taylor Swift forever And then we threw it in here And we Add in Some other string behind And Ever Right So we write it in the document Which is here After the sum content We get I'll learn Taylor Swift forever And ever Right That's really it So So we've seen how that We can actually Add Content on the fly Using JavaScript So Right We've done some pretty amazing work Just like that We've seen Learned We've seen Our syntax itself This This is just the beginning Of JavaScript And how we What we can even do With JavaScript So there's a lot more We can do Let's see what we can do Right So We can Drink some water And continue talking With a Bad troll Okay So I think I'm Probably losing my voice soon So okay So now We've got We'll do this Adding the ID The ID attribute Into Our Division Like that Right And Actually Is this correct? Ya, this is correct Okay, so Now What I'm going to do is that I'm going to go to Test.html I'm going to Do some break lines Right I'm going to do two break lines And then I'm going to refresh Then you see that There's some space here Right You see that space there I added two break lines there So The document.write Only appended to the Last Area there Right You saw it You only appended to the last part But now What if I want to Appended Up here In this In this particular Some content Right Well, we can do that With what we We can We can do this We can do the document.getElementById Content.write So let's see what happens Copy this Put it over here In app.js So You go and look around for this ID Content Right If it's able to find it Then you go Write Write So Recently There's news on the Zika virus So there was a region that had like A total reported cases of A total reported They had Total reported Cases for party pollution 369 So again There's someone Post a picture Of the mosquito Doing the Gang chance Ya So ya, I run got this So let's refresh the page And see what happens next So hopefully it works I don't know if it's not It doesn't work I don't know if it doesn't work So let's just Do it the hack Hackish way Hold on I think it's innerHTML equals Okay So what I did was I go and Overwrite The previous content that we had I just went to Get an innerHTML And then I I just overwrote the content So let me try to pan it Can I do this? I think I can do this Let's see what happens Ya I can So I appended Using the plus Equal sign I appended the data Using the plus equals Like just how Like how you do math Right But you can do it with strings as well Because strings are essentially characters Right They are just Characters They are really just an Array of characters Or something like that So we done We done this We call it on the same line Even though there was So it was It's essentially inside The If you inspect the element You see down here that This ID It was content And within this data cell You got some content I love Taylor Swift Whatever and ever So Ya Because I've been writing so much Broken JavaScript So this is What you write in Like 4AM in the morning This is the kind of code you write 4AM in the morning So ya So Well If you look at it It's kind of getting A bit more complicated And complicated And complicated Right So People will say Please send help Well Help is here So Interesting to you JQuery Library Which we were Really introduce you Before But we're going to Reduce you Again We know That the JQuery Library Is this And the bootstrap depends on JQuery Library But what exactly Is this JQuery Day Right Is it Another SQL language No It's a Javascript Library So What is this Javascript Library Doing here Right So We've got It's Well It's really a Javascript Library To help you Cut down a lot of codes It's Like Bootstrap But for Just Javascript Right Something like that Think of it that way So We're still about Original Content like that But if we have If we have JQuery Which I'm going to copy at this I don't trust My own code anymore So I'm going to Look At my other code That seems to be More reliable So I'm going to copy JQuery Library Where is this JQuery Library Copy And I'm going to paste it Test.html Right Above This .js Right What do I copy? JQuery JQuery library I copy it already So now I have the power Of JQuery Right So just What is this JQuery does So I think This script I type And trust it I'm just going to copy it Alright So What do I type? I think let me just Yeah It's the same So It'll Do exactly the same thing Yeah It just did Exactly the same thing So I cannot stress How many times I have to stress this Because It's getting Ready Stressed So anyway JQuery Library It's huge Bootstrap It's huge Don't use them If you Only just need Some parts of them Right Don't use it If you If you Don't need it That much If it's just What small project Don't use it Right Writing Just your javascript Right It's fine enough Right Okay So We did this Right So Let's take a look At a code again So Remember the hashtag In CSS Well There was this in the Round of JQuery Right So the hashtag If you remember It's actually Pointing towards an ID Right So The ID here Is Pointed at content Right So we pointed to content Right So let's see Here You say this ID equals content Right And then hashtag Content So What is this thing over here What is What is this magical thing here Right How come it's so powerful It cuts short so much code Right Well, this is what we call a selector Right It's The JQuery selector That allows you to select even classes Class elements Ideal elements Or elements by their name itself Right Or even Sudo classes Attributes And everything All of them can be selected Using this powerful Magical Marvels Of JQuery Right So we use the selector Then we use This This Function Quad A pan Right So we have pan Whatever Start with one And then we edit it Right So another benefit of using JQuery Is that It does the normalization for you Right So because of some whatever stupid reasons There are some difference between internet Exploder And Like Things like Firefox or Chrome So Your screen Your Javascript That works In internet Exploder Might not work On Chrome Right So in the past That was something like that So Front-end developers had a hell of a work to do Right And The This small particular company called Microsoft Didn't abide by the open standards Which The open standards of Eggmascript Right So Eggmascript is the Javascript itself Right Eggmascript versions Different kind of Eggmascript versions So right now we are in Eggmascript <IP_ADDRESS> So every year There will be a new release of Javascript Ya So they are aiming for that So there will be a new release of Javascript standards Every year Including New functionality such as Reduce Lab Etc But There are always some issues with those So So The normalisation across the browser Makes it easier for you Because You no longer really have a care so much Into building Cross-browser compatibility Right You don't have to spend so much fiddling out Why doesn't this crap work On internet exploder What must I do Right So There's a time spent on that So A lot of normalisation being done For you And making your life a bit easier Of course That's For So now we have learnt about selectors And Functions Within jQuery itself So if you visit the jQuery website You will see Obviously there's some documentation available For you to look up upon So jQuery.com Has this search Thing here You can look up on the functions that are available Such as a pen So when you hit the search button Are you kidding me? Okay so I'll just use So we've got Wonderful documentation available for this Apis Dot a pen Then you'll say Blah blah blah Insert content Blah blah blah blah Blah blah blah Blah blah blah So this wonderful Flu flash Documentation for you Out there to explore Right We previously introduced to you CSS We previously introduced to you HTML And the guide was to use Mozilla Development Network MDN For you to look up on the documentation itself Right So for JavaScript You can also use MDN And for jQuery You've got jQuery.com And for PHP You've got PHP.net That provides Really really full flash documentation Out there That really works Right So That's for appending Well Let's add in more Additional complexities That we don't really Need to do Yes we do So We've got this Thing called Document.ready Which is like a Listener It listens It listens More than the bosses That talks And does nothing Right It listens to you It listens to all your sad things It listens to your Christ at night So it's a really wonderful body That you have And you can use it For the rest of your life Right So Use this Thing That we have your listeners Within JavaScript itself We have listeners That are Really really nice So What is this thing Doing here Is that It's listening For the document To be ready So when the Document is ready It fires an event out And says Okay The document has been loaded And it's ready Do we launch The nuclear rockets right now So After that This listener Picks up It picks up the event That has been broadcasted out Then They will call to this Anonymous function Here Function Bracket Bracket Bracket Sounds like a frog So It will execute Whatever is here Right So Why do we even need to listen For the document To be ready Right Sometimes Even When we put it At the bottom of it Even when we put it At the bottom of the document The document might not have been fully loaded Or something like that There might be some scenarios Or if when you put your You decided to be crazy And put your Javascript file At the top So When that happens You need this thing called Document.ready That listens For the event Of the document Ready Broadcast So When that happens You have this So I'm just going to add this in It's a really simple function I don't even remember A simple function like that So it loads See So if you If you If your eyes are sharp enough Look carefully You'll see something blink Right You'll see the word I love Taylor Swift That blink Okay You saw it blink Did you saw it? Saw that So It was It was waiting for the document To be fully ready And when that event fired Saw it coming And then Boom The text came out And was appended to it So that's what happens So we basically introduced One One of the We don't really have a lot of time Okay So we basically introduced One of the listeners The document listener Right So there are also other listeners Out there So we're going to really, really Cut To the chase So A normal function Is a function that has no name So what happens JavaScript is loaded JavaScript needs some of the documents No finished event Document finished loading And fires the event JavaScript is loaded Looks for an HTML element With an ID of content JavaScript appends I love Taylor Swift forever And ever To the HTML element That was what happened So now we're going to Add in a form Actually We're just going to Add in this For now So Ya This will be integrated later I don't think We have enough time For that Today So I'm just going to Copy this form Here So Notice how I don't even have anything Hold on We don't even follow this Actually Ya We just look at it first I'm going to brief me We don't even have time I've got five minutes To show you what happens Okay So Now we're going to Do a form validation Okay So It's going to listen For submit event We're going to Point at a form And then we're going to Listen for the submit event Right It's not listening For the submit event And execute the function With it So standard thing Listen Document Finish loading And fire the event Just give it a listen For the form With an ID Login form the fire Or submit event Right So we're going to Do like a serialization And then Ya This is This is long So it's going to serialize the data And then Become a key and value So it's going to be Object If a key And a value Right The key Is the name The value Is whatever is the input So the key Will be something like Let's say The key Will be something like username And the value Of the key Will be the input It's somewhat Like the Get and post Global variable Something like that It's somewhat similar Except So we're doing something similar To To what we previously did in PHP Which was the four-ish loop Right So this loop through All the data And then we Keep a look out for For a name That is user name Right So after that We check We do a Like check Check it Actually this looks Very wrong This is wrong This should be This should be value Data.value Data.value.length Ya, this is value Not key Smaller than 3 Then alert Username to short So Basically what happens Is when The person submits The login And the username Is too short Then It will Pop up the Thing and say Oh username is too short Right Something like that So So this is This is what happens Right JS Listen for the form With an ID Login It attach It attaches the listener To This Particular element That's the ID Login form Right And it listens for the Summit event Right And then when it's submitted Then JavaScript Look through all the form data And input And look for the out for the username JavaScript then Check the input for the username And see if it's shorter Than 3 characters If yes Or With the message Right So That's it For Our JavaScript I mean more At the end of JavaScript So But that's it For today's workshop So That's kosher Of really quick summary Of what we've learned so far We've learned Page resessions How we can attach Cookies Onto our client browser And we even Identify them We've learned More about databases In particularly Relational database And we've learned PHP data objects JavaScript syntax Which is What we've already learned before Which is very similar To the PHP syntax itself And we've got We've learned about More in that Into the JQuery library JavaScript functions The normal functions and all And of course JavaScript listeners We went through the JavaScript part A bit Quickly today And we're going to Go More We're going to Do a better revision Next week So For next week We'll be covering The last part The last part of To JavaScript itself And Deployment Deployment Of your website Right So I think We'll be most Likely deploying To Azure I think Okay So next week We'll be Talking into more Platforms That we deploy into That's There's famous one such as Heroku Azure Google Cloud OpenShift And Many, many more Platforms out there That we can deploy our cloud Deploy our cloud into For Ya So That's it If you have any questions Feel free to stay behind and ask Email me or anything If not Thank you for coming today And Have a Sampai jumpa And Thank you To Jun Hao For Doing the recording And Thank you As well For helping out Thank you