PDA

View Full Version : Php



sXenoG
08-07-2005, 04:48 AM
Im having issues. I started my own text rpg not available to the public mostly just as alearnign experience to myself. But I seem to have an issue with my log in method for some reason I cant seem to CACHE what people enter in forms.

ex:
A user types info into a form clicks on a link then goes and the text is gone. It only seems to be an issue in my game as other scripts on my site seem to support caching just fine without me doing a thing. I believe that my login system is hurting it but could be wrong. If you need more info let me know ill post my script as i dont care if anyone hacks it lol :).

FX
08-08-2005, 11:25 AM
If your login system operates using a database in any capacity, then you're going to need to remember to POST your variables to it, or, include the values to your variables in an array of some sort for interpretation by the following page.

Another option, is to post your variables to a php page with no visible elements which calculates the validity of those variables, and redirects to another that and assigns an array with information that your rpg can then use to operate from. Javascript can be used efficiently to grab and pass variables along as well.

A 3rd and probably more efficient option in this case would be to take the field info and write it to a cookie stored on the person's computer, where each page of your rpg would then grab the required information to be displayed from the cookie, and if required, rewrite the cookie with new info as required.

If you want an example of how effective cookies are, this site operates with cookies, storing session and permission information on them. Remove the cookie, and you'll need to re-login so the software knows who you are, and what access level you're at, as well as any other information we ask it to filter.

Hope this helps.

sXenoG
08-08-2005, 02:09 PM
It helps very much but I dont fully understand all of it. Ive also had no luck with cookies at all ill try those again. I dont feel that posting to blank pages is an option for me.

I kno that the website I got the idea I started does use cookies however so im going to opt to learn this method.

I have a book that attmepted to explain how to code cookies but the scripts didnt work so before I go looking on my own do you know of some good tutorials for cookies.

You also seem very very knowledgeable and perhaps you could answer one more question for me. The rpg i currently play makes it soy ou cant type url to game feature, if you do it logs you out (you dont have ot log back in you can use the back feature) So bassicly Id like to know how i can make it so you can only navigate through my site using links i provide. Do you kno how to destroy sessions if someone types it in or how to place an error page if someone does so (the game i play is done in cgi but all features of cgi seem to be present in php.)also I kno the game isnt ending the session sicne you can use the back feature without having to relogin.

FX
08-08-2005, 05:02 PM
well.....

The game seems to use a form of logging, and if it's in cgi (which I'm less familliar with) I'm sensing that it's using sessions to track who's logged in and playing. If you try to bypass it, then your session doesn't exist, and it forces you to re-login. The game appears to update the session as you progress, but trying to jump ahead seems to force it to look for a session variable that doesn't exist yet, and so it does the same as though you hadn't been playing and forces you to re-login. Hitting the back button basically takes you back to where the session value was valid and resets the time-out value so you can keep playing. It may not end the session, just resets the value....bypassing the session creation by directly typing the URL of the place you want to go means certain required variable info isn't being written and the code basically send you back to the start recognizing you're in the wrong place.

First thing I'd do is look through the code to see where it looks for session info and see if there's an expiry or timelimit to the session. Next I'd look at the code where you pass from one area in the game to another, and see what info is being written. I'm thinking that each area of the game is coded with a progression factor coded into the session, which the site keeps constant record of. Where that's recorded and how it's used is beyond me, and truly most of this is guess work because I don't fully understand how this rpg operates, but logically, once you log in, it records a session, and that session contains your login info, as well as where you are in the rpg. As you progress, it updates the session info with new info AND requires that info to be correct in order to proceed further, which would explain why you aren't able to type a URL in and go from there.

Changing session info shouldn't be that hard, however, if it's progressive session validation (meaning the sessions are updated based on current status) you're either going to have to eliminate session timelimits, or rewrite how progress information is handled....this is where cookies become more useful.

Wish I could help more, but this is my interpretation.

sXenoG
08-08-2005, 09:21 PM
Actually I dont have the code or I prolyl would have figured it out. Until about 2 months ago i never made a php script in my life.

I play an online rpg that inspired me to do this so i could learn php since it had a HUGE number of feature i could emulate and learn how to program using php. Ive learned alot about php but dont kno ALL of its ins and outs as of yet. Im also very poor at security which is something I need to learn.

Anyways what you said reminded me of an article I read about php and MIGHT just have the answer im looking for. I believe you can pass certain information on using links in php I dont remember how but i kno that you can only allow certain information to be passed when pressing a link durring sessions. I think i blew that information. But say you have $variable=1 well using sessions you can pass to the next page that $variable=1. Well lets say you did this you could have your login page set the variable to one and have every page pass that value thru the session. once that variable DID not = one because someone typed ina URL then the session would not end but then people could not proceed. Do you kno of such a thing or believe its plausable if so Ill be doing some research :)

Ooo and just to let you know im not a total newb with php im intermediate in my opinion. So far ive created a login system, chat room, battle system, a map feature that shows on an image where youre located on a map (you can move, north west east south and it shows your progression.) A small searching device for my game. I havent done ne program in the last 3 weeks os im a bit rust on the syntax and all. Last week i made a small tax calculator just for practice.
http://www.primodezign.com/tax/
just a little simple device not my best caliber but just so you dont have to feel like ur wasting your time with someone who knows nothing.




Also I just had a question about the caching. Why would the cookies effect the caching? Would it just be because it would be a different log in system? I wasnt too keen on that part of ur last post.

FX
08-09-2005, 03:24 AM
What you're referring to are arrays. What you're looking at if I'm understanding correctly is something like game.php&id=player&round=1&level=3. As long as the page you're linking to knows to grab the variables as they're passed, yes, that will work.

Cookies can work 2 ways, actual cookies, or use sessions. Every visitor that comes to the site is issued a session when using php. That information is stored on your computer in either a specific directory, or in a root dir. Cookies and session info can be used to track and time a person's time at a site, and store information passed in variable arrays like the one I showed earlier. Cookies work with caching, and tell the site how to proceed using the information passed along, and can actually be used to update important information stored in it.

Hope this helps.

sXenoG
08-09-2005, 07:33 AM
Yea it does ill be looking at cookies more and NO its not an array i do kno waht those are lol :) ill post an example script of waht im talking about when i get a chance i need to go find my book then i can show you what i mean :)