Jump to content

premiso

Members
  • Posts

    6,951
  • Joined

  • Last visited

  • Days Won

    2

Everything posted by premiso

  1. What I recently started doing is having a directory called includes inside that have a classes directory and functions directory etc. Inside those I have files which I name func.main.php or class.db.php so I can have my data sorted easily. Using this you probably do not need the extra directory structure, but it can be nice. OOP is a good way to go if you are using PHP5 since PHP4 is limited use, it can be very frustrating. Frameworks can be nice, but really just sloppy and can make coding harder because half the time you have to re-code them to get them to do what you need. As far as a tutorial for structuring code, I do not think you will find one as it is really a personal preference for each person. As for the league, no clue. Hope that helps.
  2. setcookie('loggedin', true, false, '/', false, 0); setcookie('mysite_username', '$username', false, '/', false, 0); You were missing a "false" in the second set cookie. I believe that is the issue.
  3. <?php foreach ($array as $val) { echo $val . "\n<br />"; } ?>
  4. Well are you doing a mod_rewrite or is the file being called included through a different file? Remember PHP thinks PHP_SELF is the original script. So if you have a mod_rewrite to send let's say www.yourdomin.com/help to www.yourdomain.com/main.php?action=help well the main.php is going to be the php_self file, not help/index.php Just a little fyi.
  5. Post the form code, chances are you do not have the enctype defined.
  6. Fourspaces sucks you can try and convert all 4 spaces into tabs. <?php $var = str_replace(" ", "\t", $file); $newoutput = explode("\n\t", $var); ?> But that is flawed in its own sense too. If you are expecting tabs but are getting 4 spaces, sounds like you need to fix the original file.
  7. First off mysql will throw an error cause you are using double quotes. (not to mention php also for a syntax error) MySQL uses single quotes around data. You would access form elements by $_POST['fieldname'] You would have to run mysql_query() on each of those statements, as the way you have it only the last statement would be executed.
  8. Because register_globals is off (like it should be) you need to access php_self via $_SERVER['PHP_SELF']
  9. UPDATE `packages` SET `name` = 'Pkg 1. Complete Sound', `price` = '895', `desc` = 'Package priced fo up to 4 hours performance time. Package includes up to 3 hours complimentary set-up time, MC service from your chosen Disc Jockey throughout the evening, 2 Professional JBL Powered Speakers, Wireless Microphone, Custom-built Disc Jockey unit with Professional Grade equipment.' WHERE `pkgID` = '1' desc is a reserved keyword, use backticks around table and column names (`). Single quotes go around data like you have them.
  10. You need to use $_FILES instead of $_POST['file']. You may want to take a look at this: http://us3.php.net/features.file-upload as it seems you are just guessing.
  11. if ($_SERVER['REQUEST_METHOD']=="GET" && $_GET['Item']!="") { You are missing a { on that line.
  12. No, session variables are unique to user/browser session. If someone was using the same browser and logged out and then logged back in, the session data should be overwritten. But you should kill the session data when a user logs out. Also session data usually has a life span of 20 minutes default I believe, something like that. I am not sure how closely PHP follows it but yea. The key is that sessions are completely independent of each other as long as the user is using a different computer/browser. I generally store login information in cookies hashed up to verify that against the DB, so the cookie keeps the user logged in and not sessions for that exact reason of a browser closing. Anyhow I think you are worrying too much. Once again, sessions are completely independent of each other.
  13. Obviously no one has an answer. The issue seems to lie within your server/server hardware. Simple as that, upgrade the server the problem is solved.
  14. Have you tried adding the path and domain to the setcookie? Are you on localhost or a live server? <?php setcookie("email", "", time() - 3600, '/', '.domain.com'); setcookie("password", "", time() - 3600, '/', '.domain.com'); Header("Location: test.php"); ?> It also depends on how you set the cookies initially, post that code. Incase you are trying this on localhost I suggest you read this article: http://www.aeonity.com/frost/php-setcookie-localhost-apache
  15. www.php.net/cURL You may want to look into curl, although that is for mainly retrieving data from a site. Another way is to use a hidden form which is submitted via javascript. Finally why not just use Sessions? Those are the only ways I know.
  16. The session variables are independent of users and browsers. The session will stay alive for the lifetime of the browser (unless you use your own session scheme). But when a browser closes that user's session is wiped out essentially. The only concern you might have is session hi-jacking, which is only a concern on Shared hosting. You should be fine. Sessions are independent of each other.
  17. I guess either way I am making a trip to the database. The goal is to have the options available globally (via session). So I guess checking against the timestamp works and just keep the data in session will be how I go. It will definitely be under 5KB so I doubt there will be a problem. Thanks for the input bud.
  18. $query = mysql_query("SELECT stixy FROM emailists WHERE stixy = '{$session->userinfo['email']}'"); You were missing the ending ) paran.
  19. Hello All, Have a question about storing data in session. I have a blog site with users of course. Instead of having to make a call to getUserData() each time I want user data inside a function (or defining it globally) I thought about storing the data in a session variable and doing one of two things. Keeping that throughout the lifetime of the session, and only re-querying if a change has been made since the request was pulled (Date field in the user table of last_modified) or just storing it in session and un setting the data each page. Not sure which (if any) is better. Most likely there will be about 20 fields stored, username, email, and some options the user is able to set which should only be boolean variables. I think storing it in session and testing against the timestamp would work great but before I start coding this for my whole site would like to know some input. Thanks!
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.