Phil Roberts wrote:
With total disregard for any kind of safety measures Stewart
Robert Hinsley <{$******@meden.demon.co.uk> leapt forth and
uttered:
I've just finished my first PHP script (fronted at
<URL:http://www.malva ceae.info/Index/Vernacular/index.html).
One thing is puzzling me - when parsing the query string
split("&", $QUERY_STRING) works, but
split('&', $QUERY_STRING) doesn't, yet
split('=', <string>) does/
What subtlety am I missing?
Why are you doing that in the first place? PHP automatically
converts query string values for you.
Phil is correct. PHP has a solution for accessing varaibles passed in
the URL. It makes them available as an associative array called $_GET
This array variable is called a super-global. PHP also provides other
superglobals to make accessing the environment variables easier.
check them out here
http://www.php.net/reserved.variables
$_SESSION is particularly cool, but you need to run the session_start()
function first before it works. Unfortunately the above page neglects to
mention that and it has caught some people out.
As a newbie, you will want to make sure you get to know PHP's session
handling capabilities -- IT WILL SAVE YOU A LOT OF WORK!
http://www.php.net/manual/en/ref.session.php
remember that before the $_SESSION superglobal came along, it was
neccesary to use the other session functions all the time, now you can
do things like.
<?php
session_start();
if(!isset($_SESSION["uname"])) {
if(blnAutheticated($_POST)) { // use form data
$_SESSION["uname"] = $_POST["uname'];
}
else {
header("Location: login.php"); // redirect them
die();
}
}
echo "You are currently logged in as ".$_SESSION["uname"];
?>
obviously the above code requires you to write a blnAutheticated()
function which accepts an associative array that it will search for
authentication tokens.
No fartin' about with cookies and what not...
hmmm... I seem to have gotten a bit side-tracked...
------------ And now a word from our sponsor ------------------
Want to have instant messaging, and chat rooms, and discussion
groups for your local users or business, you need dbabble!
-- See
http://netwinsite.com/sponsor/sponsor_dbabble.htm ----