On Monday, July 1, 2002, at 11:30 AM, Adrian Greeman wrote:
> Would it be true to say that every time an example is given where data > is > passed on (for forms and so forth) that I can simply replace the > variable in > the example with $_POST or $_GET? Or do I have to do more? Pretty much. If the data was passed by a "get"-method form, or through the querystring, then the variable should be in the _GET array (such as $_GET['variablename']). Likewise for "post"-method forms, and any cookie variable names are now "$_COOKIE['variablename']". Server variables like $PHP_SELF are now $_SERVER['PHP_SELF'], and you can read the rest under "predefined variables" in the manual at the web site. > eg if a simple PHP file for handling form input takes in the data using > $LastName can I simply use $_POST["LastName"]?? It seems to work for a > very > simple example. But should I read the array into a variable first? Only if you want to -- you can always just refer to it as $_GET['variablename']. In fact this is probably better for memory use. > And do > I need to do any validation or declaring of variables etc?? [I did > have a > problem reading in a number - the solution was to put (int) before the > POST > array name though I don't understand why that was not needed with a > string. All POSTed or GETed data is string data, so if you for some reason explicitly need to cast the variable as an integer, then yes, you need to use (int). But in many cases PHP does this automatically. > I am also unclear what happens when you send something using header() - > does that also go into an array - if so which one and how do I use it? I'm assuming you mean sending some querystring data, like header("Location: http://domain.com/page.php?data=contents"); if so, then yes, you will end up with the string 'contents' in a variable called $_GET['data'] . Erik ---- Erik Price Web Developer Temp Media Lab, H.H. Brown [EMAIL PROTECTED] -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php