A fundamental characteristic of Web is:
- The stateless interaction between browsers and web servers
- Each HTTP request sent to a web server is independent of any other request.
Applications that require complex user interaction can’t be implemented as a series of unrelated, stateless web pages. An often-cited example is a shopping cart in which items are added to the cart while searching or browsing an on-line store. The state of the shopping cart (the selected items) needs to be stored somewhere to be displayed when the user visits the order page.
There are three ways to build an application that keeps state:
- Variables can be passed between scripts as query string appended with the URL.
- Variables can be stored in the browser at client-side as cookies and then can be included with each request.
- Variables can be stored on the server as session variables
Passing Variables Between Scripts
The simplest way is to add the variables to the url:
You can chain these variables using an ampersand.
As per normal you can access these variables easily. You just need to use $_GET array, and access variables through their names. E.g
$var1 = $_GET[“variable1″];
However this can lead to problems as you can’t have certain characters in url’s – spaces for example, more ampersands, colons and so on. To deal with this php has the urlencode() function.This converts all those problem characters into their url friendly counterparts. E.g.
<? $str = urlencode("script.php?name=T. J.&lastname=O’Reilly"); print "<A HREF=$str>link</A>"; ?>
You’ll get a hyperlink something like given below:
Nobody can now manipulate your link.
- 8. Sessions in PHP
- 1.PHP Basics
- 7. Cookies in PHP
- 2. PHP: Form Handling
- Converting Multipage TIFF file to JPG/GIF in PHP
- Programming Simple REST Web services with PHP
- PHP Tutorial for Beginners
- 9. AJAX and PHP
- PHP vs Java: Which is for me?
- Attendance Management System
- Getting Started with PHP
- ICTFax versus Hylafax – Which is for me?
Popular Posts (last 30 days)
- Attendance Management Sys… 1305 view(s)
- Applications of Stack in … 1031 view(s)
- Circular Linked Lists 915 view(s)
- Implementing Stack Data S… 675 view(s)
- Graph Implementation in C… 624 view(s)
- Simple Currency Converter… 535 view(s)
- Recursive Factorial funct… 338 view(s)
- Finding Minimum, Maximum … 324 view(s)
- GRASP Design Patterns 320 view(s)
- Boyer-Moore String Search… 244 view(s)
TagsAndroid C-Sharp C/C++ language Classes Data structures Design Pattern Eclipse Game Development Graphics Design Books HTML iPhone JAVA JAVA GUI MIPS Assembly Mobile Programming Books Object Oriented PDF PHP Programming Programming Books Programming Languages Books Python RaphaelJS REST Source Code Threads Tutorial Web Development Books