RE: Re: Passing variables through a page

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Sessions are better.  If you want to use the header to pass the
variable:

header("Location:5-14_select_area.php?department=$department"); (use an
ampersand "&" for adding additional variables as mentioned by Mark.

You should call a clean function from an include file (add the document
root directory in the php.ini file so you can place the file in a
different directory and PHP always knows where to find it when you
"include" it without having to reference the entire document root - very
handy) to prevent someone from altering your intended input (this is why
sessions are better).
<?php
//include.inc
function clean($input, $maxlength)
{
	$input = substr($input, 0, $maxlength);
	$input = EscapeShellCmd($input);
	return ($input);
}
?>

Then for the 5-14_select_area.php file:

<?php
//5-14_select_area.php
include_once 'include.inc';

if(!empty($department))
{
  $department = clean($department, 15);
}
if(!empty($level))
{
  $level = clean($level, 15);
}
your queries follow
......

?>

Hope that is what you were looking for.

Michael Conway
mconway3@cox.net
(703) 968-8875
 

-----Original Message-----
From: Mark [mailto:mark_weinstock@yahoo.com] 
Sent: Tuesday, January 07, 2003 10:29 AM
To: php-db@lists.php.net
Subject: Re:  Re: Passing variables through a page

If you use sessions, you can pass the variables without having to
wory about interim pages. Another option (I don't know if it will
actually work) is to put the variables in the the URL of the location
redirect. Something like:

$loc="http://www.yourdomain.com/nextpage?var1=$var1&var2=$var2";;
header("location: $loc");


--- Michael Mauch <michael.mauch@gmx.de> wrote:
> Alex Francis <afrancis@camerondesign.co.uk> wrote:
> > I have a page (dept_select) with two drop down lists populated
> from a table
> > in a MySQL Database. If one item is selected in either of the
> lists I need
> > to go to one page (5-14_select_area.php). If any other item is
> selected I
> > need to go to another page (add_new_resources.php) but I need to
> pass the
> > selected items to add_new_resources.php.
> 
> I don't think there are many other possiblities, at least if you
> don't
> want to use JavaScript (and I hope you don't).
> 
> Instead of the redirect, you could perhaps use require() to include
> one
> of the two possible pages, and thus avoid one server-client
> roundtrip.
> 
> > At the moment I have created a page between dept_select.php and
> the other
> > pages and added the following code to it:
> > <?php
> > if ($department=="5-14 Curriculum")
> > {
> > header("Location:5-14_select_area.php");
> > }
> > elseif ($level=="5-14 Curriculum")
> > {
> > header("Location:5-14_select_area.php");
> > }
> > else
> > {
> > header("Location:add_new_resources.php");
> > }
> > ?>
> 
> The Location header requires an absolute URI, e.g.
> http://your_host/path/your_file.php.
> 
> I'm not sure whether this is a database question ;-)
> 
> Regards...
> 		Michael
> 
> -- 
> PHP Database Mailing List (http://www.php.net/)
> To unsubscribe, visit: http://www.php.net/unsub.php
> 


=====
Mark Weinstock
mark_weinstock@yahoo.com
***************************************
You can't demand something as a "right" unless you are willing to fight
to death to defend everyone else's right to the same thing.
-Stolen from the now-defunct Randy's Random mailing list.
***************************************

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com



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


[Index of Archives]     [PHP Home]     [PHP Users]     [Postgresql Discussion]     [Kernel Newbies]     [Postgresql]     [Yosemite News]

  Powered by Linux