Jump to content

KodiTiger

Members
  • Posts

    11
  • Joined

  • Last visited

    Never

Everything posted by KodiTiger

  1. Yay, success, thanks so much for all of your help everyone !
  2. Okay, I got rid of the session destroy thing, it's still not putting the username where it should ... Is just blank.
  3. I'm not sure :S , the guide I'm using said to do that when I'm done with it. I'm just trying to get a basic login working for now, and so I need the session to be destroyed after the greeting so that I can log in as another member and create a new session. I think, anyway :S ? I'm very new to this...
  4. I've just tried both of those things and I still get the error and output given in reply #8 .
  5. Thanks for that Rifts, that's great! Now that login.php page is working, my game.php page is as follows: <?php echo "Welcome "; echo $_SESSION['name']; echo " , you have logged in successfully."; session_unset(); session_destroy(); ?> Unfortunately, it doesn't seem to remember the session name from the login page? How can I make it greet me? It currently outputs: "Welcome , you have logged in successfully. Warning: session_destroy() [function.session-destroy]: Trying to destroy uninitialized session in /www/99k.org/s/i/m/simbazeviangame/htdocs/game.php on line 8" Thanks a lot!
  6. My latest code (for the whole page this time) is: <?php $counterInt = 0; // Make a MySQL Connection mysql_connect("localhost", "<username here>", "<password here>") or die(mysql_error()); mysql_select_db("<database name here>") or die(mysql_error()); // Get all the data from the "Players" table $result = mysql_query("SELECT * FROM Players ORDER BY name") or die(mysql_error()); // Keeps getting the next row until there are no more to get while($row = mysql_fetch_array( $result )) { if(($row['name'] == $_POST['name']) && ($row['password'] == $_POST['password'])) { $counterInt = 1; session_start(); $_SESSION['name']=$row['name']; } } if(counterInt == 1) { header( 'Location: http://simbazeviangame.99k.org/game.php' ); } if(counterInt == 0) { echo "Login or password wrong!"; } ?> Thanks a lot .
  7. Okay, I've changed the =s to ==s and & to && in the if statement. It still comes up with username or password wrong... So something else is wrong :S ...
  8. Why is my code below not working properly? I've tried it with == instead of = and it still doesn't work. I've verified using echo statements that $row['name'] = $_POST['name'] and $row['password'] = $_POST['password'] for one of the people in my database, but it still gives the message "Login or password wrong!" Thanks a lot for any help, here is the relevant part of my code (counterInt is defined to be 0 further up): while($row = mysql_fetch_array( $result )) { if($row['name'] = $_POST['name'] & $row['password'] = $_POST['password']) { $counterInt++; session_start(); $_SESSION['name']=$row['name']; } } if(counterInt == 1) { header( 'Location: http://simbazeviangame.99k.org/game.php' ); } if(counterInt == 0) { echo "Login or password wrong!"; }
  9. Hi go easy on me please, I'm a PHP newbie. I've got a HTML form that posts information to a PHP page. This PHP page runs some code and has a counterInt that is = 1 if everything is okay, and is = 0 otherwise. I want the PHP page to automatically redirect to another PHP page if counterInt = 1. But using the header() redirect thing apparently doesn't let me already have code before it. How can I make it redirect at the appropriate point in my code, if and only if counterInt is 1? Thanks very much .
  10. Thanks very much , got a working timer now!
  11. Newbie PHP user here, so go easy on me . I've been trying to make a timer that starts on an arbitrary number of seconds, say 10 for example, then counts down to 0 (and refreshes itself every second for the user to see how much time is remaining), and then some more code is executed when 0 is reached. I attempted to do something like: <?php $goal = time() + 10; while($goal - time() >= 0) { echo "$goal - time()"; sleep(1); } ?> This didn't seem to work as my page just took a while to load - I suspect it was going through the entire while loop before displaying anything rather than just dynamically updating the timer every second. Also when I chose 100 instead of 10, the webpage didn't seem to even finish loading. Also it displayed a lot of odd text - not a timer at all! Help would be much appreciated !
×
×
  • 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.