PHP-and-MySQL/C2/GET-Variable/English-timed
From Script | Spoken-Tutorial
Revision as of 11:35, 10 July 2014 by Pratik kamble (Talk | contribs)
Time | Narration |
---|---|
00:01 | Welcome to this Spoken Tutorial on get variable. |
00:09 | Get variable is a very useful variable type. |
00:17 | It is used for most of the dynamic website with forms that have click-able buttons. |
00:27 | It's also visible to the user.You may have seen anything like this on your page. |
00:33 | Let us click on this.You may have seen something like this, a question mark. |
00:39 | Say for example, name equals to Alex. Something similar may have appeared in your address bar. |
00:47 | You may have seen 'and' something else as well, for example your name equals to Kyle |
00:54 | This is the get variable. |
00:56 | What it basically does is, it takes submitted data from an HTML form. Puts it in the storage which we're supposed to use. And,it's just in your address bar. |
01:08 | The get variable has limitations. It can only be a 100 characters long. It is visible to the user. So, it's not good to use it for a password. |
01:20 | Now, to create the use for this, you don't need to declare it, as the other variables in Php. |
01:28 | I'm going to say echo , then a dollar sign, an underscore and a get. |
01:33 | And in square brackets you need to write the name of the variable for example, "my name" . |
01:40 | This is all I need to basically echo out, i.e, what has been posted in a form. Even though I don't have a form , I can still mimic this. |
01:51 | What I do is I put a ? and I say my name is equals to Alex. Then I press enter and the data is displayed. |
02:03 | The same way I can write Kyle or any other name or variable I want |
02;09 | It can be numbers, letters or strings. |
02:15 | Now, I'm going to show you how to submit a form using the get method. |
02:22 | Basically,I'm going to create an HTML page. |
02:30 | I'm going to have a form and the action of the form. |
02:34 | If you haven't learnt HTML already, it would be very useful to learn it before you start working with this. |
02:44 | The action is going to be in the same pace that we're working with. This method is going to equal get because that's the method we're using. Finally, you can end your form like that. |
02:58 | We're going to need an input box and it's name is very important. |
03:03 | I'm going to call it 'my name' which is the variable that's going to appear. |
03:11 | We're also going to need a submit buzzer. In the input type 'submit' put some user friendly value like 'click here'. |
03:26 | Refresh it and there you go.Just leave this as it is. |
03:33 | Let me type the name 'Alex' and click here.You can see this is changed here. It is giving my name, which is the name of this box here. Also it's giving the value of what I've typed in. |
03:47 | So, now what I want to do in Php is, echo out this value. |
03:52 | I'll start quoting underneath this HTML. It is possible to incorporate Php and HTML on one page. So long as it is not between Php tags. Unless it's in an echo function. |
04:07 | Now, let' say name is equal to dollar sign, underscore, get. |
04:14 | And, in my name, I better mind this has to match this. Otherwise you won't get any response. |
04:20 | Then just say echo and Your or just Hello and then name. |
04:31 | Let's get rid of this and start again. |
04:35 | We've already got hello. |
04:40 | And using an if, I'll type in Alex, since I clicked that. |
04:48 | This is how Alex appears. But now we've a problem. We've got Hello and then a blank here with a full stop. We want to get rid of that. |
05:06 | You just have to say 'if name' because we've already got one line.We don't need curly brackets and name itself is present.So, it's true. |
05:23 | If there's no value sent to name this will automatically assume as false. Therefore it won't execute this. |
05:33 | So, Refresh.There, it's gone. |
05:39 | We have our value in and I click there. |
05:42 | It's detected that a value is present here and it's echoed out. |
05:47 | So,that's the end of the get variable. |
05:50 | In my next tutorial, I will talk about the post variable and it's uses. This is Anoushka for the Spoken Tutorial Project. Thanks for watching. |