Jump to content

thirdearth

New Members
  • Posts

    6
  • Joined

  • Last visited

    Never

Profile Information

  • Gender
    Not Telling

thirdearth's Achievements

Newbie

Newbie (1/5)

0

Reputation

  1. Thanks. The alert popping up is annoying, but the idea itself worked like a charm!
  2. Hi there. I've been working on a PHP-based web game for quite some time that is coming out great, but I have run into a problem. A lot of the aspects of the game involve clicking "submit" form buttons, and use a PHP isset command to update the mysql database based on what you clicked. Example if I was trying to go North: <form name="form" action="playerhome.php" method="post"> <input type="submit" name="north" id="north" value="North" /> </form> <?php if (isset($_POST["north"])) {$longitude--; $herodirection = "heroup"; mysql_query("UPDATE members SET herodirection = '$herodirection', y='$longitude' WHERE login = '$login'"); header('Location: playerhome.php'); } } ?> Its more complicated than that, but not relevant to my question. The problem is that while everything works great if you single click around in the game, problems arise when people click any buttons in rapid motions and start getting multiple clicks in before the form refreshes the page. I thought I could use the javascript disable function to disable the button after it was pressed, but when I did that, any PHP within the isset command would no longer run. Can anyone think of a way with PHP to prevent multiple submits?
  3. Can you clarify a little? Are you just wanting it to pull the previous 5 months from whatever month you pulled out of the table? Or the previous 5 months that an event happened? Do you have any code of what you are trying to accomplish? Without knowing exactly the purpose you are trying to accomplish here, I will assume that you are trying to output the previous 5 months of the calendar year. There are many ways that you could do this. If they are listed in incremental order within this table, you could move your LIMIT 1 to LIMIT 6. If that doesn't work, you could always create a new table with a first column that lists all of the months in the year, then the second column with their previous 5 months, or something to that nature. Then, when you want to call those previous months, simply do a select on the table you just created like so: SELECT month1, month2, month3, month4, month5 FROM table WHERE currentmonth = $variable Am I even on the right track?
  4. I actually have the same dilemma *I think* as MadnessRed. My login script uses Sessions in PHP. Now, when someone logs in, here is what happens: // Code begins here $qry="SELECT * FROM members WHERE login='$login' AND passwd='".md5($_POST['password'])."'"; $result=mysqli_query($link,$qry); if($result) { if(mysqli_num_rows($result) == 1) { session_regenerate_id(); $member = mysqli_fetch_assoc($result); $_SESSION['SESS_MEMBER_ID'] = $member['member_id']; $_SESSION['SESS_LOGIN'] = $member['login']; session_write_close(); mysqli_query($link,"UPDATE members SET online = 'yes' WHERE login = '$login'"); // Code ends here The result works absolutely fine. The problem lies in trying to sign on as more than 1 user on the same computer. Let's say "User 1" signs on. He does whatever he wants, but for some reason, he needs to be on 2 account *as a game example, maybe he needs to pass himself an item ingame from another character of his friend's*. So he logs onto "User 2" by opening a new window. What happens in my script is that the second login Session overrides the first, and now both windows are "User 2". Everytime it tries to pull $login, they both read the same Session. Is this the same kind of issue you are referring to Madness? Anyone have any ideas on how I can either make it set different Sessions, or get rid of Sessions completely for a login script?
  5. Wow, I just noticed that there was a sticky regarding this issue.  Guess I should look around before I go posting replies that have probably been answered a thousand times.
  6. Usually that issue, at least in my experience, is because you are sending a header function after something else is already being outputted.  All header functions have to be processed before any code *even blank space* can be outputted. http://us3.php.net/manual/es/function.header.php There are 2 ways that I know of to fix this.  First one is to make sure that you are only using the header function at the top of all processed pages, before any other code is ran.  The second, and easier, way to handle this is ob_start and ob_end_flush functions. http://us.php.net/ob_start If you use those on the page, then everything between them will buffer before any code is outputted.  As to why it just started happening, I can't tell you.  Did anyone change your configuration of PHP?  My guess is that there was some sort of error reporting option that was turned off before and someone turned on.  I had the same issue when I swapped a PHP-driven site from a host to my personal web server and I used output buffering to fix it.
×
×
  • 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.