When browsing the website, users may need to type in some information and interact with the visualised web page. in fact, it is possible to customise the page to visualise by choosing some parameters. Each parameter is treated as a value and it is assigned to a variable. Now, the browsing session will be according to the defined setting in all next pages set by a freelance web designer Singapore. The fact is, the parameters converted into values and assigned to their respective variables have been passed from one page to another. This process allows you to browse without the need to re-enter or specify the parameters for every single visited page. The variables are commonly passed included within the URLs.
Assigning values to the variables:
This operation is called affecting values. The syntax is in general like this:
variable name = variable value;
definitely, this line will erase the previous value within the variable and replace it with the new one, unless the new value is void.
The value is obtained in several ways. It can be:
- The user input (form, mouse events…)
- The result of a particular
- The pre-set value of the variable.
Including variables in the URLs strings:
Inserting the variables in the URL string is made by three selectors; two are obligatory and the third one is conditional. The model of the URL string containing variables is as follow:
‘target_page?variable1=value&variable2=value’ when working on the same website
www.some_domain_name.extension?variable1=value&variable2=value, if the variables are sent to another website.
The (?) symbol: is the concatenation selector. It tells the server that the following strings are variables. It is used to instruct the server to add the variables instead of erasing the URL string.
The (=) symbol: it is the assignment sign which tells the server that the variable contains the assigned value.
The (&) symbol: it separates the variables.
The variables are used according to two methods: POST and GET. Those two methods are not only different by the way they carry they receive the variables but also by the way they submit the variables to the destination page.
Retrieving the variables from the URLs:
The variables included in the URL string are retrieved using particular scripts. In fact, each scripting language has the specific functions that allow it handling the variables passed in the URL string. For example, PHP scripting requires setting modules that will identify the variables and will create similar variables to receive the values. The variables are defined and they are assigned their respective values using different methods that match POST or GET method.
$variable1=$_POST ($_GET)[‘variable1’];
It is important to signal that the methods POST and GET are usually specified at the form level. Actually, they are values of the attribute method of the HTML element form.
Once received, the variables are available for use as any other variable in the target page. They can be displayed, stored in the database, or embedded in another URL to be sent to another web page.
Conclusion:
Passing variables using URLs is one easy method to exploit the entries on one page in all the website. However, this practice may have some downsides which can alter the integrity of the website and may create some bugs in the scripts. Fortunately, there are ways to prevent these problems and keep the website safe.