Difference between revisions of "PHP-and-MySQL/C2/GET-Variable/English-timed"
From Script | Spoken-Tutorial
Sandhya.np14 (Talk | contribs) |
Sandhya.np14 (Talk | contribs) |
||
Line 22: | Line 22: | ||
|- | |- | ||
|00:47 | |00:47 | ||
− | |You may have seen 'and' something else as well, for example your name equals to "Kyle". | + | |You may have seen 'and' (&) something else as well, for example your name equals to "Kyle". |
|- | |- | ||
|00:54 | |00:54 | ||
Line 28: | Line 28: | ||
|- | |- | ||
|00:56 | |00:56 | ||
− | |What it basically does is, it takes submitted data from an '''HTML form'''. Puts it in the storage which | + | |What it basically does is, it takes submitted data from an '''HTML form'''. Puts it in the storage which you were supposed to use and it's just in your '''address bar'''. |
|- | |- | ||
|01:08 | |01:08 | ||
Line 37: | Line 37: | ||
|- | |- | ||
|01:28 | |01:28 | ||
− | |I'm going to say '''echo''' , then a dollar sign ($), an underscore and a ''' | + | |I'm going to say '''echo''' , then a dollar sign ($), an underscore (_) and a '''GET'''. |
|- | |- | ||
|01:33 | |01:33 | ||
Line 43: | Line 43: | ||
|- | |- | ||
|01:40 | |01:40 | ||
− | |This is all I need to basically '''echo''' out | + | |This is all I need to basically '''echo''' out which is what has been posted in a '''form'''. Even though I don't have a '''form''', I can still mimic this. |
|- | |- | ||
|01:51 | |01:51 | ||
− | |What I do is, I put a | + | |What I do is, I put a question mark (?) and I say '''myname''' is equals to "Alex". Then I press '''Enter''' and the '''data''' is displayed. |
|- | |- | ||
|02:03 | |02:03 | ||
Line 67: | Line 67: | ||
|- | |- | ||
|02:44 | |02:44 | ||
− | |The '''action''' is going to be in the same | + | |The '''action''' is going to be in the same page 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 | |02:58 | ||
− | |We're going to need an '''input box''' and it's name is very important. | + | |We're going to need an '''input box''' and it's '''name''' is very important. |
|- | |- | ||
|03:03 | |03:03 | ||
− | |I'm going to call it ' | + | |I'm going to call it 'myname' which is the variable that's going to appear. |
|- | |- | ||
|03:11 | |03:11 | ||
− | |We're also going to need a '''submit''' buzzer. In the '''input''' | + | |We're also going to need a '''submit''' buzzer. In the '''input type''' 'submit', put some user friendly '''value''' like "click here". |
|- | |- | ||
|03:26 | |03:26 | ||
Line 91: | Line 91: | ||
|- | |- | ||
|04:07 | |04:07 | ||
− | |Now, let' say '''name''' is equal to dollar sign, underscore, ''' | + | |Now, let' say '''$name''' is equal to dollar sign, underscore, '''GET'''. |
|- | |- | ||
|04:14 | |04:14 | ||
− | |And, in ' | + | |And, in 'myname', I better mind this has to match this. Otherwise you won't get any response. |
|- | |- | ||
|04:20 | |04:20 | ||
− | |Then just say '''echo''' and Your or just ''' | + | |Then just say '''echo''' and "Your" or just "Hello," and then '''$name'''. |
|- | |- | ||
|04:31 | |04:31 | ||
Line 103: | Line 103: | ||
|- | |- | ||
|04:35 | |04:35 | ||
− | |We've already got " | + | |We've already got "Hello,". |
|- | |- | ||
|04:40 | |04:40 | ||
Line 112: | Line 112: | ||
|- | |- | ||
|05:06 | |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 ''' | + | |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 | |05:23 | ||
− | |If there's no value sent to '''name''' this will automatically assume as ''' | + | |If there's no value sent to '''$name''' this will automatically assume as '''False'''. Therefore it won't execute this. |
|- | |- | ||
|05:33 | |05:33 | ||
− | |So, '''Refresh'''.There, it's gone. | + | |So, '''Refresh'''. There, it's gone. |
|- | |- | ||
|05:39 | |05:39 |
Revision as of 12:50, 26 May 2015
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 you were 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: "myname". |
01:40 | This is all I need to basically echo out which is 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 question mark (?) and I say myname 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 page 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 'myname' 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 'myname', 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 its uses. This is Anoushka for the Spoken Tutorial Project. Thanks for watching. |