On Tuesday 17 June 2003 11:39, Logan McKinley wrote:

Use a descriptive subject heading.

> I am new to PHP but have been using ASP for years.  What i am trying to do
> is:
> 1) take a querystring variable
> 2) set it as a session variable
> 3) redirect the page back on itself
>     all of this is done so the user never sees the querystring var so it
> must change it address bar
> 4) access the session variable as a hidden form element
>
> The code that follows is code i tried to write but it doesn't seem to work
> <----------------------->
> <?
> $qs = "";
> session_start();
> if($_SERVER['QUERY_STRING']!="" && $_Session("qs") != "")
                                      ^^ A ^^  ^ B ^

A) PHP variable names are case-sensitive, $_SESSION != $_Session
B) You probably want to replace the () with [].

> {
> $_SESSION["qs"] = $_SERVER['QUERY_STRING'];
> session_register("qs");

You cannot (should not) mix the use of $_SESSION with session_register(). 
RTFM.

If you redirect without closing the session then any changes to the session 
variables will lost. So you need a session_write_close(). 

> header("Location: http://localhost/PHP/registration_form.php";);
> }
> ?>

> among other problems if there is no querystring value at all it gives me an
> error in the if statement

Use:

 isset($_SESSION['qs'])
or 
 !empty($_SESSION['qs'])
rather than
 $_Session("qs") != ""

and similarly for $_SERVER['QUERY_STRING'].

-- 
Jason Wong -> Gremlins Associates -> www.gremlins.biz
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
------------------------------------------
Search the list archives before you post
http://marc.theaimsgroup.com/?l=php-general
------------------------------------------
/*
La-dee-dee, la-dee-dah.
*/


-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to