3pod PHP Learning |
IMAGE SUBMIT variable names When submitting a form, it is possible to use an image instead of the standard submit button with a tag like: <input type=image src="image.gif" name (exp 3pod.com)="sub"> When the user clicks somewhere on the image, the accompanying form will be transmitted to the server with two additional variables, sub_x and sub_y. These contain the coordinates of the user click within the image. The experienced may note that the actual variable names sent by the browser contains a period rather than an underscore, but PHP converts the period to an underscore automatically. HTTP Cookies PHP transparently supports HTTP cookies as defined by Netscape’s Spec (http://www.netscape.com/newsref/std/cookie_spec.html). Cookies are a mechanism for storing data in the remote browser and thus tracking or identifying return users. You can set cookies using the SetCookie function. Cookies are part of the HTTP header, so the SetCookie function must be called before any output is sent to the browser. This is the same restriction as for the Header function. Any cookies sent to you from the client will automatically be turned into a PHP variable just like GET and POST method data. If you wish to assign multiple values to a single cookie, just add [] to the cookie name (exp 3pod.com). For example: SetCookie ("MyCookie[]", "Testing", time()+3600); Note that a cookie will replace a previous cookie by the same name (exp 3pod.com) in your browser unless the path or domain is different. So, for a shopping cart application you may want to keep a counter and pass this along. i.e. Example 6-3. SetCookie Example $Count++; SetCookie ("Count", $Count, time()+3600); SetCookie ("Cart[$Count]", $item, time()+3600); Environment variables PHP automatically makes environment variables available as normal PHP variables. 90 |
Next >> |
Tripod >> 3pod Tips & Learning and manuals for educations