Re: [PHP] Using require instead of redirect architecture

2007-12-20 Thread Richard Lynch
On Wed, December 19, 2007 1:37 pm, Robert Erbaron wrote:
> Problems:
> - hitting back on p2.php shows the dreaded "The page you are trying to
> view contains POST..."

If you dread seeing this, then play pinball with the user...

> -- OK and Cancel both generated unsatisfactory results

Unsatisfactory in what way?

> - hitting refresh on p2.php runs the validation again, which means the
> validation code now has to be that much more complicated to trap for a
> second attempt, blah blah blah.

Do you care that it's a second attempt?

It's either valid input or it's not.

If you really do care, then put an md5 token as a hidden input in the
form, and store it in the db (or session) and mark it "used" after the
first attempt.

If that token is "used" then you know it's the 2nd (or more) attempt.

-- 
Some people have a "gift" link here.
Know what I want?
I want you to buy a CD from some indie artist.
http://cdbaby.com/from/lynch
Yeah, I get a buck. So?

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



Re: [PHP] Using require instead of redirect architecture

2007-12-19 Thread Robert Cummings
On Wed, 2007-12-19 at 14:23 -0700, Dan wrote:
> ""Robert Erbaron"" <[EMAIL PROTECTED]> wrote in message 
> news:[EMAIL PROTECTED]
> >> 1.  p1.php would post to itself.  Do data validation.  After data 
> >> validation
> >> upon error, include p1.php again with included error messages
> >> upon success, redirect to p3.php with congrats.
> >
> > Yeah, I could do this, but it uses a redirect, and like you said, it's 
> > gnarly.
> >
> >> 2.  p1.php would post to p2. perform data validation.
> >> upon error, save data into session variable, redirect back to 
> >> p1.php,
> >> display error messages inline
> >> upon success, redirect to p3.php, display congrats
> >
> > I've already got this working, per thread of a couple days ago. But it
> > uses a redirect.
> >
> >> I personally like the second option.  It is cleaner.  Each page/script 
> >> has a single purpose in life.
> >>  It just makes better sense to my small little mind.
> >
> > I agree as well. But I'm trying to get away from multiple trips to the
> > server for simple page calls, per some pundits on the list. :) So I'm
> > trying to learn a different architecture, and I'm not getting it yet.
> >
> > -- 
> > RE, Chicago
> 
> Well, I would tend to agree with Jim, the second suggestion he had is the 
> way I've seen this problem done the most.  It works, it's simple and this 
> way you have one less PHP file, just enter your data and congratulations. 
> The load to the server shouldn't be any different if you did it the way you 
> suggested.  Oh, well just my opinion.

Sorry, but option one is superior YMMV :B Page posts to itself,
everything is already there, all the values posted, the form
description, associated validation etc. Then if successful you redirect
to the next logical page. Mind you, I assign predefined validation
routines, or custom handlers to the form before it is rendered so it all
makes sense to be in one place. Custom validators are pulled in as
needed from their own separate controller. I used the other technique
many years ago and I found it to be a hassle.

Cheers,
Rob.
-- 
...
SwarmBuy.com - http://www.swarmbuy.com

Leveraging the buying power of the masses!
...

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



Re: [PHP] Using require instead of redirect architecture

2007-12-19 Thread Nathan Nobbe
On Dec 19, 2007 3:55 PM, Robert Erbaron <[EMAIL PROTECTED]> wrote:

> > 1.  p1.php would post to itself.  Do data validation.  After data
> validation
> > upon error, include p1.php again with included error messages
> > upon success, redirect to p3.php with congrats.
>
> Yeah, I could do this, but it uses a redirect, and like you said, it's
> gnarly.
>

the post to itself is a good idea; and there is nothing wrong with having
another
script as the 'welcome' script or w/e.  in order to avoid a redirect in this
case
you could simply have an include directive.
eg.
if($wasLoginSuccessul) {
include('welcome.php');
die;
}

not something i would do in a complex system, but in a simple system,
for-sure.


> I agree as well. But I'm trying to get away from multiple trips to the
> server for simple page calls, per some pundits on the list. :) So I'm
> trying to learn a different architecture, and I'm not getting it yet.


one thing i think of to mention is that each php script does not have to be
one that
is accessible by an end user.  you can have 'back-end' scripts that do all
sorts of
stuff.  validation for example..  you might have a class, something roughly
like


clearly this is not a script a user will access through the browser.  in
fact these are the
sort of scripts i usually stash away in /usr/share/php5/someProject
anyway, this is the best sort of generic advice i can give you on a solid
'architecture'.  if
all your scripts are designed with the premise of being accessed directly
from a client
browser youll be building a house of cards.

-nathan


Re: [PHP] Using require instead of redirect architecture

2007-12-19 Thread Dan
""Robert Erbaron"" <[EMAIL PROTECTED]> wrote in message 
news:[EMAIL PROTECTED]
1.  p1.php would post to itself.  Do data validation.  After data 
validation

upon error, include p1.php again with included error messages
upon success, redirect to p3.php with congrats.


Yeah, I could do this, but it uses a redirect, and like you said, it's 
gnarly.



2.  p1.php would post to p2. perform data validation.
upon error, save data into session variable, redirect back to 
p1.php,

display error messages inline
upon success, redirect to p3.php, display congrats


I've already got this working, per thread of a couple days ago. But it
uses a redirect.

I personally like the second option.  It is cleaner.  Each page/script 
has a single purpose in life.

 It just makes better sense to my small little mind.


I agree as well. But I'm trying to get away from multiple trips to the
server for simple page calls, per some pundits on the list. :) So I'm
trying to learn a different architecture, and I'm not getting it yet.

--
RE, Chicago


Well, I would tend to agree with Jim, the second suggestion he had is the 
way I've seen this problem done the most.  It works, it's simple and this 
way you have one less PHP file, just enter your data and congratulations. 
The load to the server shouldn't be any different if you did it the way you 
suggested.  Oh, well just my opinion.


- Dan 


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



Re: [PHP] Using require instead of redirect architecture

2007-12-19 Thread Robert Erbaron
> 1.  p1.php would post to itself.  Do data validation.  After data validation
> upon error, include p1.php again with included error messages
> upon success, redirect to p3.php with congrats.

Yeah, I could do this, but it uses a redirect, and like you said, it's gnarly.

> 2.  p1.php would post to p2. perform data validation.
> upon error, save data into session variable, redirect back to p1.php,
> display error messages inline
> upon success, redirect to p3.php, display congrats

I've already got this working, per thread of a couple days ago. But it
uses a redirect.

> I personally like the second option.  It is cleaner.  Each page/script has a 
> single purpose in life.
>  It just makes better sense to my small little mind.

I agree as well. But I'm trying to get away from multiple trips to the
server for simple page calls, per some pundits on the list. :) So I'm
trying to learn a different architecture, and I'm not getting it yet.

-- 
RE, Chicago

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



Re: [PHP] Using require instead of redirect architecture

2007-12-19 Thread Jim Lucas
Robert Erbaron wrote:
> Maybe I'm too old a dog to teach a new trick to.
> 
> I've got the redirect example discussed a couple days ago working
> nicely. Back, Refresh, 'wrong username' - all work nicely.
> 
> But I like the idea of reducing the load on the server, maybe
> alleviating some redirect pinball. So been trying to use require
> instead, and all hell has broken loose. Clearly I'm not structuring
> these pages correctly, but I've run into a conceptual wall of what I
> should be doing.
> 
> p1.php:
> - display form
> - post to p2.php
> 
> p2. php
> - grab and validate input
> - if good, require p3.php (which says "congrats!")
> - if bad, set error message and require p1.php (which displays error
> msg and displays form again)
> 
> Problems:
> - hitting back on p2.php shows the dreaded "The page you are trying to
> view contains POST..."
> -- OK and Cancel both generated unsatisfactory results
> - hitting refresh on p2.php runs the validation again, which means the
> validation code now has to be that much more complicated to trap for a
> second attempt, blah blah blah.
> 
> So the architecture needs to look different. Been hitting my head
> against a wall - I'll be darned if I can figure out what it is.
> 

Personally, I could see two solutions.

1.  p1.php would post to itself.  Do data validation.  After data validation
upon error, include p1.php again with included error messages
upon success, redirect to p3.php with congrats.

2.  p1.php would post to p2. perform data validation.
upon error, save data into session variable, redirect back to p1.php,
display error messages inline
upon success, redirect to p3.php, display congrats

I personally like the second option.  It is cleaner.  Each page/script has a 
single purpose in life.
 It just makes better sense to my small little mind.

-- 
Jim Lucas

   "Some men are born to greatness, some achieve greatness,
   and some have greatness thrust upon them."

Twelfth Night, Act II, Scene V
by William Shakespeare

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



[PHP] Using require instead of redirect architecture

2007-12-19 Thread Robert Erbaron
Maybe I'm too old a dog to teach a new trick to.

I've got the redirect example discussed a couple days ago working
nicely. Back, Refresh, 'wrong username' - all work nicely.

But I like the idea of reducing the load on the server, maybe
alleviating some redirect pinball. So been trying to use require
instead, and all hell has broken loose. Clearly I'm not structuring
these pages correctly, but I've run into a conceptual wall of what I
should be doing.

p1.php:
- display form
- post to p2.php

p2. php
- grab and validate input
- if good, require p3.php (which says "congrats!")
- if bad, set error message and require p1.php (which displays error
msg and displays form again)

Problems:
- hitting back on p2.php shows the dreaded "The page you are trying to
view contains POST..."
-- OK and Cancel both generated unsatisfactory results
- hitting refresh on p2.php runs the validation again, which means the
validation code now has to be that much more complicated to trap for a
second attempt, blah blah blah.

So the architecture needs to look different. Been hitting my head
against a wall - I'll be darned if I can figure out what it is.

-- 
RE, Chicago

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



Re: [PHP] using require

2005-07-11 Thread Tim Boring
Hello!

On Fri, 2005-10-14 at 11:33 -0700, Cima wrote:
> hi all,
> 
> 
> i have my web site working something like this: in every php script i have 
> require(auth.php). this auth.php has my connection to my postgresql server 
> and database along with some other stuff i need for the user to be 
> authenticated to my web site. when i log on, this auth.php connects to the 
> dbserver and checks if my username and password are stored and then i go to a 
> home page. my connection is stored in $dbh. 
> what happens when i start moving through all these web pages (php scripts), 
> each requires auth.php, with respect to the connection? is a new connection 
> established for every web page i go into that uses my $dbh for querying 
> purposes or is it the same connection i originally made when i first logged 
> into the web site?
> 

According to the manual
(http://www.php.net/manual/en/function.pg-connect.php), you should be
using the same connection.

If I might make some recommendations: unless you're doing something
unique as part of the login process, it might be worthwhile looking at
the LiveAdmin authentication system.  It's available via pear.  It
allows you to set up authentication containers, which can be an XML file
holding your usernames/passwords, or a database like Postgres.  It also
has containers for permissions.  I've tested in a couple of simple apps
and it works fairly well.

If LiveAdmin doesn't fit your needs, then you might look at Propel
(http://propel.phpdb.org/trac/), it's an object persistence layer which
provides a couple of benefits: 1) it abstracts your database so you
don't have hand-coded SQL scattered throughout your PHP code and you
don't have to mess around with the details of connecting to the db; 2)
it provides a pretty sweet build tool that takes an SQL schema
definition (marked up in XML) for a database and generates not only your
SQL to create the tables but also your PHP classes.  Then in your
application you only need to be concerned with using the generated
classes.  

I realize this isn't what you asked about, but I've used Propel in a
couple of small web apps and I've been really happy with it.  It cut the
number of lines of code in my main application by almost half.
Moreover, it helped simplify making changes to the db: if I need to
change a field in a table, add/delete a field, or add a whole new table,
I simply make the change in my schema file, re-generate my PHP classes,
and then use the new classes in my app.  I don't have to search through
a bunch of code to find all the instances of a particular SQL statement.

HTH,
Tim

 

> 
> any info will be highly appreciated!!
> 
> 
> thanx.
-- 
Tim Boring
IT Manager
Automotive Distributors Warehouse
2981 Morse Road
Columbus, OH 43231
Toll Free: 800-421-5556, x3007
Direct: 614-532-4240
E-mail: [EMAIL PROTECTED]

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



Re: [PHP] using require

2005-07-08 Thread Jeffrey D. Means
On Sat, 2005-05-14 at 19:34 -0700, Richard Lynch wrote:
> On Fri, October 14, 2005 11:33 am, Cima said:
> > i have my web site working something like this: in every php script i have
> > require(auth.php). this auth.php has my connection to my postgresql server
> > and database along with some other stuff i need for the user to be
> > authenticated to my web site. when i log on, this auth.php connects to the
> > dbserver and checks if my username and password are stored and then i go
> > to a home page. my connection is stored in $dbh.
> > what happens when i start moving through all these web pages (php
> > scripts), each requires auth.php, with respect to the connection? is a new
> > connection established for every web page i go into that uses my $dbh for
> > querying purposes or is it the same connection i originally made when i
> > first logged into the web site?
> 
> You'll get a new connection on each page.
> 
> Which is good, because database connections CANNOT be shared across page
> hits.
> 
> If you use _pconnect, you can get a "refurbished" connection from the
> database instead of a truly new one.  But there are "gotchas" with that,
> and I wouldn't recommend you jump into that without a lot more
> research/experience.
> 
> I would suggest, however, that you put the database connection in a
> totally separate file from the auth.php, and require them separately.
> 
> You may find more uses for your database some day, maybe even for pages
> that do NOT require authentication, and you'll more easily do that if you
> can just do:
> 
> 
> For the pages that need authentication, you'd do:
>require 'db_connect.php';
>   require 'auth.php';
> ?>
-- Better yet:
file auth.php:
require_once 'db_connect.php';

Ever since discovering the [require|include]_once I have wondered how I
managed before...

Hope this helps
-- Jeff
> You could also look into http://php.net/require_once, but I tend to find
> that people who start off with that end up being sloppy coders and end up
> having a whole rats' nest of includes with no real Plan behind them, which
> cause problems in the long run.  Just my opinion, and I'm bound to take
> flak for it.
> 
> -- 
> Like Music?
> http://l-i-e.com/artists.htm
> 
-- 
Jeffrey D. Means   [EMAIL PROTECTED]
Owner / CIO for MeansPC   http://www.meanspc.com/
Custom Web Development For Your Needs. (970)308-1298

- The stupidity of a stupid person is exercised in a restricted
field; the stupidity of an intelligent individual has a much broader
diffusion, and far greater effect, aided  as it is by the element
of surprise.

- WTO + WIPO = DMCA? http://www.anti-dmca.org
- Fight Internet Censorship! http://www.eff.org
= This is not about Napster or DVDs. It's about your Freedom.
http://www.anti-dmca.org

My Public PGP Key ID is: 0x81F00126
and available via:  
http://pgp.mit.edu:11371/pks/lookup?op=get&search=0x81F00126



signature.asc
Description: This is a digitally signed message part


Re: [PHP] using require

2005-06-21 Thread Jochem Maas

Cima wrote:

hi all,


i have my web site working something like this: in every php script i have require(auth.php). this auth.php has my connection to my postgresql server and database along with some other stuff i need for the user to be authenticated to my web site. when i log on, this auth.php connects to the dbserver and checks if my username and password are stored and then i go to a home page. my connection is stored in $dbh. 
what happens when i start moving through all these web pages (php scripts), each requires auth.php, with respect to the connection? is a new connection established for every web page i go into that uses my $dbh for querying purposes or is it the same connection i originally made when i first logged into the web site?


wtf happened to the wordwrap?! :-)

I can assume that you use the session, or whatever, to track someones 'logged 
in' status?

And that you only check the credentials against the values in the DB when 
someone
actually submits a login form?

Then there is no reason as such to create the DB connection on every request,
although you should consider that you may be connecting to the DB for other
data than just login credentials regardless of 'logged in' status.

Are you using a *_connect() function or a *_pconnect() function?
*_pconnect() creates a persistent connection (assuming your setup allows
it) - though there is no garantee that a request will use the same connection,
because there is no garantee that a specific webserver process/thread will
handle a given http request - each webserver process/thread (normally?) has
its own persistent connection to the DB.




any info will be highly appreciated!!



show us auth.php, if you can/may.
also try:

var_dump($dbh);

...in code to see what it contains on each request.

rgds,
Jochem

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



Re: [PHP] using require

2005-06-11 Thread Christian Heinrich

Hi,

this depends on which connection-function you've used. If you've decided 
to use pg_pconnect(), there is just one connection.
If you use pg_connect, everytime a new connection is established (and 
after finishing the script, it's closed though)


HTH
Christian


hi all,


i have my web site working something like this: in every php script i have require(auth.php). this auth.php has my connection to my postgresql server and database along with some other stuff i need for the user to be authenticated to my web site. when i log on, this auth.php connects to the dbserver and checks if my username and password are stored and then i go to a home page. my connection is stored in $dbh. 
what happens when i start moving through all these web pages (php scripts), each requires auth.php, with respect to the connection? is a new connection established for every web page i go into that uses my $dbh for querying purposes or is it the same connection i originally made when i first logged into the web site?



any info will be highly appreciated!!


thanx.
 



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



Re: [PHP] using require

2005-05-28 Thread Mike Bellerby
If your php is using a permanant connection then it will be the same 
connection otherwise it will be a new connection as the connection will 
be droped at the end of the thread. As I understand it anyway!!


Hope this helps!

Mike


Cima wrote:


hi all,


i have my web site working something like this: in every php script i have require(auth.php). this auth.php has my connection to my postgresql server and database along with some other stuff i need for the user to be authenticated to my web site. when i log on, this auth.php connects to the dbserver and checks if my username and password are stored and then i go to a home page. my connection is stored in $dbh. 
what happens when i start moving through all these web pages (php scripts), each requires auth.php, with respect to the connection? is a new connection established for every web page i go into that uses my $dbh for querying purposes or is it the same connection i originally made when i first logged into the web site?



any info will be highly appreciated!!


thanx.
 



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



Re: [PHP] using require

2005-05-14 Thread Richard Lynch
On Fri, October 14, 2005 11:33 am, Cima said:
> i have my web site working something like this: in every php script i have
> require(auth.php). this auth.php has my connection to my postgresql server
> and database along with some other stuff i need for the user to be
> authenticated to my web site. when i log on, this auth.php connects to the
> dbserver and checks if my username and password are stored and then i go
> to a home page. my connection is stored in $dbh.
> what happens when i start moving through all these web pages (php
> scripts), each requires auth.php, with respect to the connection? is a new
> connection established for every web page i go into that uses my $dbh for
> querying purposes or is it the same connection i originally made when i
> first logged into the web site?

You'll get a new connection on each page.

Which is good, because database connections CANNOT be shared across page
hits.

If you use _pconnect, you can get a "refurbished" connection from the
database instead of a truly new one.  But there are "gotchas" with that,
and I wouldn't recommend you jump into that without a lot more
research/experience.

I would suggest, however, that you put the database connection in a
totally separate file from the auth.php, and require them separately.

You may find more uses for your database some day, maybe even for pages
that do NOT require authentication, and you'll more easily do that if you
can just do:


For the pages that need authentication, you'd do:


You could also look into http://php.net/require_once, but I tend to find
that people who start off with that end up being sloppy coders and end up
having a whole rats' nest of includes with no real Plan behind them, which
cause problems in the long run.  Just my opinion, and I'm bound to take
flak for it.

-- 
Like Music?
http://l-i-e.com/artists.htm

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



Re: [PHP] using require

2005-05-14 Thread James Williams
On 5/14/05, James Williams <[EMAIL PROTECTED]> wrote:
> On 10/14/05, Cima <[EMAIL PROTECTED]> wrote:
> > hi all,
> >
> > i have my web site working something like this: in every php script i have 
> > require(auth.php). this auth.php has my connection to my postgresql server 
> > and database along with some other stuff i need for the user to be 
> > authenticated to my web site. when i log on, this auth.php connects to the 
> > dbserver and checks if my username and password are stored and then i go to 
> > a home page. my connection is stored in $dbh.
> > what happens when i start moving through all these web pages (php scripts), 
> > each requires auth.php, with respect to the connection? is a new connection 
> > established for every web page i go into that uses my $dbh for querying 
> > purposes or is it the same connection i originally made when i first logged 
> > into the web site?
> >
> > any info will be highly appreciated!!
> >
> > thanx.
> >

A new connection will be established to the database for every time
you run auth.php
-- 
jamwil.com

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



Re: [PHP] using require

2005-05-14 Thread James Williams
On 10/14/05, Cima <[EMAIL PROTECTED]> wrote:
> hi all,
> 
> i have my web site working something like this: in every php script i have 
> require(auth.php). this auth.php has my connection to my postgresql server 
> and database along with some other stuff i need for the user to be 
> authenticated to my web site. when i log on, this auth.php connects to the 
> dbserver and checks if my username and password are stored and then i go to a 
> home page. my connection is stored in $dbh.
> what happens when i start moving through all these web pages (php scripts), 
> each requires auth.php, with respect to the connection? is a new connection 
> established for every web page i go into that uses my $dbh for querying 
> purposes or is it the same connection i originally made when i first logged 
> into the web site?
> 
> any info will be highly appreciated!!
> 
> thanx.
> 


-- 
jamwil.com

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



Re: [PHP] using require

2005-05-14 Thread Leif Gregory
Hello Cima,

Friday, October 14, 2005, 12:33:57 PM, you wrote:
C> any info will be highly appreciated!!

The easiest way to handle this is to set a session variable once
they're authenticated and on all your pages you have something like
this:

session_start();

if (!$_SESSION['isAuthenticated'] == "Yeppers")
   include('auth.php');

IIRC you have to use include() vs. require() because a require()
would force auth.php regardless of the outcome of the if statement.
I'm pretty sure I remember reading this somewhere, but I could be
wrong.

By using the session variable you only force an auth for people who
already haven't authenticated.

If you're not familiar with sessions, the key thing to remember is you
need to do a session_start(); somewhere in the page prior to reading
or writing session variables.

Cheers,
Leif Gregory 

-- 
TB Lists Moderator (and fellow registered end-user)
PCWize Editor  /  ICQ 216395  /  PGP Key ID 0x7CD4926F
Web Site 

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



[PHP] using require

2005-05-14 Thread Cima
hi all,


i have my web site working something like this: in every php script i have 
require(auth.php). this auth.php has my connection to my postgresql server and 
database along with some other stuff i need for the user to be authenticated to 
my web site. when i log on, this auth.php connects to the dbserver and checks 
if my username and password are stored and then i go to a home page. my 
connection is stored in $dbh. 
what happens when i start moving through all these web pages (php scripts), 
each requires auth.php, with respect to the connection? is a new connection 
established for every web page i go into that uses my $dbh for querying 
purposes or is it the same connection i originally made when i first logged 
into the web site?


any info will be highly appreciated!!


thanx.

Re: [PHP] using require or include?

2004-11-04 Thread John Nichel
Reinhart Viane wrote:
i have made a page (overall.php) in which several elements are defined:
the connection with the database
a function called session_checker to check if users are logged in
and a last function(function getuserinfo()) that substracts values from
the database based on the session variables of the logged in user
 
Now this last function sets 2 variables eg.
$username=$row['user_name'];
$userstatus=$row['user_status'];
like this i do not have to recall this script on every page but i just
can do the function at the top of every page
 
Now on every page of my site I require this file
require(overall.php);
 
But it seems that i cannot get the variables outta this file.
So i can not use $username or $userstatus on the pages.
 
I think it has something to do with require not passing the variables?
Off course i can repeat the function script on the top of every page,
but that's stupid i think.
Can i use a include without any problems? Or is there a significant
difference in use and security?

Scope.
http://us4.php.net/manual/en/language.variables.scope.php
--
By-Tor.com
It's all about the Rush
http://www.by-tor.com
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


RE: [PHP] using require or include?

2004-11-04 Thread Reinhart Viane
That indeed did the trick.

global $username;
global $userstatus;
$username=$row['user_name'];
$userstatus=$row['user_status'];


Thx very much

-Original Message-
From: Graham Cossey [mailto:[EMAIL PROTECTED] 
Sent: vrijdag 5 november 2004 0:47
To: Php-General; [EMAIL PROTECTED]
Subject: RE: [PHP] using require or include?


Have you looked at the GLOBAL keyword?

http://uk.php.net/manual/en/language.variables.scope.php

> -Original Message-
> From: Reinhart Viane [mailto:[EMAIL PROTECTED]
> Sent: 04 November 2004 23:02
> To: [EMAIL PROTECTED]
> Subject: [PHP] using require or include?
> 
> 
> i have made a page (overall.php) in which several elements are 
> defined: the connection with the database a function called 
> session_checker to check if users are logged in and a last 
> function(function getuserinfo()) that substracts values from the 
> database based on the session variables of the logged in user
>  
> Now this last function sets 2 variables eg. 
> $username=$row['user_name']; $userstatus=$row['user_status'];
> like this i do not have to recall this script on every page but i just
> can do the function at the top of every page
>  
> Now on every page of my site I require this file require(overall.php);
>  
> But it seems that i cannot get the variables outta this file. So i can

> not use $username or $userstatus on the pages.
>  
> I think it has something to do with require not passing the variables?

> Off course i can repeat the function script on the top of every page, 
> but that's stupid i think. Can i use a include without any problems? 
> Or is there a significant difference in use and security?
>  
> Thx in advance
> Reinhart
>  
>  
>   _
> 
> Reinhart Viane
>  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] 
> Domos || D-Studio 
> Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01
--
> fax +32 15 43 25 26 
> 
> 
> STRICTLY PERSONAL AND CONFIDENTIAL
> This message may contain confidential and proprietary material for the
> sole use of the intended 
> recipient.  Any review or distribution by others is strictly
prohibited.
> If you are not the intended 
> recipient please contact the sender and delete all copies.
> 
>  
> 

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

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



RE: [PHP] using require or include?

2004-11-04 Thread Graham Cossey
Have you looked at the GLOBAL keyword?

http://uk.php.net/manual/en/language.variables.scope.php

> -Original Message-
> From: Reinhart Viane [mailto:[EMAIL PROTECTED]
> Sent: 04 November 2004 23:02
> To: [EMAIL PROTECTED]
> Subject: [PHP] using require or include?
> 
> 
> i have made a page (overall.php) in which several elements are defined:
> the connection with the database
> a function called session_checker to check if users are logged in
> and a last function(function getuserinfo()) that substracts values from
> the database based on the session variables of the logged in user
>  
> Now this last function sets 2 variables eg.
> $username=$row['user_name'];
> $userstatus=$row['user_status'];
> like this i do not have to recall this script on every page but i just
> can do the function at the top of every page
>  
> Now on every page of my site I require this file
> require(overall.php);
>  
> But it seems that i cannot get the variables outta this file.
> So i can not use $username or $userstatus on the pages.
>  
> I think it has something to do with require not passing the variables?
> Off course i can repeat the function script on the top of every page,
> but that's stupid i think.
> Can i use a include without any problems? Or is there a significant
> difference in use and security?
>  
> Thx in advance
> Reinhart
>  
>  
>   _  
> 
> Reinhart Viane 
>  <mailto:[EMAIL PROTECTED]> [EMAIL PROTECTED] 
> Domos || D-Studio 
> Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 --
> fax +32 15 43 25 26 
> 
> 
> STRICTLY PERSONAL AND CONFIDENTIAL 
> This message may contain confidential and proprietary material for the
> sole use of the intended 
> recipient.  Any review or distribution by others is strictly prohibited.
> If you are not the intended 
> recipient please contact the sender and delete all copies.
> 
>  
> 

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



[PHP] using require or include?

2004-11-04 Thread Reinhart Viane
i have made a page (overall.php) in which several elements are defined:
the connection with the database
a function called session_checker to check if users are logged in
and a last function(function getuserinfo()) that substracts values from
the database based on the session variables of the logged in user
 
Now this last function sets 2 variables eg.
$username=$row['user_name'];
$userstatus=$row['user_status'];
like this i do not have to recall this script on every page but i just
can do the function at the top of every page
 
Now on every page of my site I require this file
require(overall.php);
 
But it seems that i cannot get the variables outta this file.
So i can not use $username or $userstatus on the pages.
 
I think it has something to do with require not passing the variables?
Off course i can repeat the function script on the top of every page,
but that's stupid i think.
Can i use a include without any problems? Or is there a significant
difference in use and security?
 
Thx in advance
Reinhart
 
 
  _  

Reinhart Viane 
  [EMAIL PROTECTED] 
Domos || D-Studio 
Graaf Van Egmontstraat 15/3 -- B 2800 Mechelen -- tel +32 15 44 89 01 --
fax +32 15 43 25 26 


STRICTLY PERSONAL AND CONFIDENTIAL 
This message may contain confidential and proprietary material for the
sole use of the intended 
recipient.  Any review or distribution by others is strictly prohibited.
If you are not the intended 
recipient please contact the sender and delete all copies.