About array

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
raulfigo
Forum Newbie
Posts: 2
Joined: Fri Aug 30, 2002 4:09 pm

About array

Post by raulfigo »

Hi all.
I have 3 pages (p1.php - p2.php - p3.php). Each this page has a code:
p1.php -> p1
p2.php -> p2
p3.php -> p3

I don't get to make the string test receive, for example, p2, p3, p1 and record this value in database. Why this ?

When the user acess p2 in first time, the script records this value in $test. If the user access again the same page, the message is "You just take it"

So, the user access only one time each page. But I cant get to record like a array, for example.

Can you help me, please ?

Thank you
User avatar
volka
DevNet Evangelist
Posts: 8391
Joined: Tue May 07, 2002 9:48 am
Location: Berlin, ger

Post by volka »

may be I didn't get the point....
Do you want to prevent users from requesting the same page/function twice?

If so, read http://www.php.net/manual/en/ref.session.php
If not, please clarify
User avatar
gite_ashish
Forum Contributor
Posts: 118
Joined: Sat Aug 31, 2002 11:38 am
Location: India

Post by gite_ashish »

Hi,

The normal variable values are NOT maintained/persisted between page visits. If you want to prevent users from visiting the same page again and again, you need to maintain session. Unlike normal variables, session variables CAN maintain/persist their values.

In case of functions, you can use static variable, which can maintain/persist their values between function calls.

:idea: See PHP man:

http://www.php.net/manual/en/ref.session.php
http://www.php.net/manual/en/language.v ... scope.html


Regards,
raulfigo
Forum Newbie
Posts: 2
Joined: Fri Aug 30, 2002 4:09 pm

Post by raulfigo »

Hi volka.
First, thank you for your attention. Sorry if I didn't explain correct. So I created test pages. So If the user make anyone this test, the user cann't to repeat the test.

So, this is the reason that I want to record the code page in a page field, in array, if it's possible.

Whe the user tries to access the page, will be deny, because the user already makes the test.

Hi gite_ashish.
Thank you too.
I use session in homepages because needs to login and password.
The reason that I want to use array, I hope that I had explain above.

Thank you for all.
Post Reply