Welcome to this Spoken Tutorial on get variable.
Get variable is a very useful variable type.
It is used for most of the dynamic website with forms that have click-able buttons.
It's also visible to the user.You may have seen anything like this on your page.
Let us click on this.You may have seen something like this, a question mark.
Say for example, name equals to Alex. Something similar may have appeared in your address bar.
You may have seen 'and' something else as well, for example your name equals to Kyle
This is the get variable.
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.
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.
Now, to create the use for this, you don't need to declare it, as the other variables in Php.
I'm going to say echo , then a dollar sign, an underscore and a get.
And in square brackets you need to write the name of the variable for example, "my name" .
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.
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.
The same way I can write Kyle or any other name or variable I want
Now, I'm going to show you how to submit a form using the get method.
Basically,I'm going to create an HTML page.
I'm going to have a form and the action of the form.
If you haven't learnt HTML already, it would be very useful to learn it before you start working with this.
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.
We're going to need an input box and it's name is very important.
I'm going to call it 'my name' which is the variable that's going to appear.
We're also going to need a submit buzzer. In the input type 'submit' put some user friendly value like 'click here'.
Refresh it and there you go.Just leave this as it is.
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.
So, now what I want to do in Php is, echo out this value.
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.
Now, let' say name is equal to dollar sign, underscore, get.
And, in my name, I better mind this has to match this. Otherwise you won't get any response.
Then just say echo and Your or just Hello and then name.
Let's get rid of this and start again.
We've already got hello.
And using an if, I'll type in Alex, since I clicked that.
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.
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.
If there's no value sent to name this will automatically assume as false. Therefore it won't execute this.
So, Refresh.There, it's gone.
We have our value in and I click there.
It's detected that a value is present here and it's echoed out.
So,that's the end of the get variable.
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.