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)
- Circular Linked Lists 1300 view(s)
- Attendance Management Sys… 1065 view(s)
- Applications of Stack in … 1058 view(s)
- Graph Implementation in C… 904 view(s)
- Implementing Stack Data S… 775 view(s)
- Simple Currency Converter… 661 view(s)
- GRASP Design Patterns 501 view(s)
- Recursive Factorial funct… 490 view(s)
- Finding Minimum, Maximum … 364 view(s)
- Implementation of Priorit… 310 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