Jump to content

ngreenwood6

Members
  • Posts

    1,356
  • Joined

  • Last visited

Everything posted by ngreenwood6

  1. Thanks for the responses guys. That cleared it up for me.
  2. I am new to php and am trying to learn. I have the basics and can do some of the more complex stuff but the one thing that I do not get is the "->" What do you use that for? How do you use it and what does it mean when you use it? For example: if(empty(username)) { do this } else { do that } That means if the user didnt enter a username do this or if they did do that. Can someone explain to me how the "->" thing works in an example like above.
  3. Sorry about the java thing. I know that java and javascript are 2 totally different things. I just wasnt paying attention when I posted the last post. Thanks for the help though. I will look into it.
  4. Can you give me an example or a good place to start? I have no java knowledge and am looking for a solution.
  5. I am trying to figure out how to set-up a php event when the window is closed. For instance I want something to be inserted into the database when the window is closed. Can someone show me how to use the window unload event with php? Thanks in advance
  6. I have a game on my website that if they were logged in twice they could be doing alot better than if they were only logged in once. I do not want others to feel cheated and I do not want anyone cheating the system
  7. What would log.php consist of though?
  8. Ok thanks for the help guys I get what you are saying and I think I know what I am going to do. However, I want to set it so that when the visit the next page it sets the current time in the database. How could I easily implement that into each page so that I do not have to add that code to every page that they will be logged into? The main thing that I dont know how to do is:
  9. I do and I have the username stored in the session but how would I use the database for this. The problem that I see is that when a user just closes the page it doesnt log them out hence not updating the database. Any suggestions? This is why I am so stumped! I know that there are websites out there that do this though.
  10. I have created a login for my website. It is working without a problem. When a user logs there username gets put into a session and they can view all the pages that they cannot when they arent logged in. However, I do not want users logging in twice with the same username. I have been trying to think of how I want to accomplish this but would like to know what your suggestions are. Please let me know how you would do it with maybe an example or tutorial. Thanks in advance
  11. Anyone? I know it is used alot so someone has to know a method of getting this accomplished.
  12. I am trying to log the users ip address. The reason for this is so that if a user logs in with an ip address no other user can log in from that same ip address at the same time. So when the user is logged in I want it to know there ip address and when they log out I want it to get rid of it. Does anyone know how I can accomplish this? I am open to any and all suggestions at this point.
  13. So maybe you can help me with this. I have my database set up to insert the users ip address into the database when they log in. Then when they log out or go to the logout.php page it removes the ip address from the database. The reason for this is so that no 2 users can log in from the same ip address. The problem with this is that if the user does not log out or go to the logout.php page it doesnt remove the ip address. Which means that they will not be able to log in again until it is removed. Is there any way that I can have it remove this when they leave the site or a better method to do this. thanks in advance
  14. Does anyone have any other suggestions then?
  15. I tried adding it to my page like this: <?php include("variables.php"); ?> <html> <title><?php echo $site_name; ?></title> <head> <link href="includes/style.css" rel="stylesheet" type="text/css" /> </head> <script> function autotab(original,destination){ if (original.getAttribute&&original.value.length==original.getAttribute("maxlength")) destination.focus() } onunload=function() { session_destroy(); } </script> <body onUnload='onunload()'> <div id="container"> <div id="head"> <br> The Ultimate Game </div> <div id="links"> <a href="index.php">Home</a> | <a href="Game.php">Game</a> | <a href="contact_us.php">Contact Us</a> </div> But I am getting an error stack overflow on line 19. Any help
  16. Is there anyway to destroy a session if the user closes the page? I need the sessions to destroy when a user exits my site.
  17. I don't think that quite fits into what I am trying to accomplish but thanks for the attempt.
  18. This is what it would look like for you: <?php $get_name = $_POST['name']; $get_email = $_POST['email']; $get_receiver = $_POST['receiver']; $get_subject = $_POST['subject']; $get_message = $_POST['message']; $to1 = "[email protected]"; $to2 = "[email protected]"; $to3 = "[email protected]"; $to4 = "[email protected]"; $subject = $get_subject; $message = $get_message; $header = 'MIME-Version: 1.0' . "\r\n"; $header .= 'Content-type: text/html; charset=iso-8859-1' . "\r\n"; $header .= "From: $get_email"; if($get_receiver == $to1) { mail($to1, $subject, $message, $header) } elseif($get_receiver == $to2) { mail($to2, $subject, $message, $header) } elseif($get_receiver == $to3) { mail($to3, $subject, $message, $header) } else { mail($to4, $subject, $message, $header) ?> Modify for your needs but you should get it from here.
  19. I was told by someone to use the session set save handler. I do not know how to use this function. Basically I am trying to prevent users from logging in from the same ip address. I want to do it with the mysql database and I have it working. However it only works if the user ends the session with the logout page. If they just close the window and dont log out it doesnt get changed in the database. So someone told me to use the session set save handler. I was hoping that someone could give me an example of how to use this function as I have googled it and can find no good resources or tutorials. If you know of an easier/better way please explain. Thanks in advance.
  20. That looks like something that could be useful but I am confused by the link that you have given to me. I am kinda a noob to php and mysql but am learning my way around. If someone could give me a basic example of how to use this session save handler to interact with mysql that would be great. Thanks in advance
  21. I have 2 values that I have stored in the database: 'logged_in_ip' and 'logged_in'. The first one logs there ip while they are logged in. The second one sets a value of 1 to logged_in when they are logged in so that no other user can log in with the same username while they are. I have set it so that when they log out it sets the ip to blank and the value of logged_in to 0. The problem that I am having is that if they dont go to the logout page and just exit the site it doesnt change these values. Does anyone know how I can force them to log out if they close the window or a better method to do this. Thanks in advance
  22. You would do an if/else statement: ex. <?php $contact1 = "[email protected]"; $contact2 = "[email protected]"; $contact3 = "[email protected]"; if($contact1) { mail(to, subject, message) } elseif($contact2) { mail(to, subject, message) } else { mail(to, subject, message)//this mails $contact3 } ?>
  23. I already have it checking the logged_in_ip. You cannot login two people from the same ip address. I want to be able to not allow a user to log in 2 times to the site from different ip addresses. Any help is appreciated.
  24. I am having a problem with getting data from the database. I am trying to have it set so that if a user is logged in it sets the "logged_in" value in the database to 1 which it does. Then if someone else tries to log in with the same username it sees that it is 1 and says someone is already logged in. Here is my code: <?php session_start(); //include database variables include("includes/variables.php"); //get variables from login form $username = strtolower($_POST['username']); $password = md5($_POST['password']); $ip_address = $_SERVER['REMOTE_ADDR']; //connect to the mysql server $connect = mysql_connect($host, $db_username, $db_password); //select the database $select_db = mysql_select_db($db); //query to select posted username from database $query = "SELECT * from $db_user_table WHERE username='$username'"; //query to enter the ip address into the database $update_query = "UPDATE $db_user_table SET logged_in_ip = '$ip_address', last_ip = '$ip_address' WHERE username = '$username'"; //query to check the database for ip address already logged in $check_ip = "SELECT * FROM $db_user_table WHERE logged_in_ip = '$ip_address'"; $ip_results = mysql_query($check_ip); $num_ip = mysql_num_rows($ip_results); //query to log user in database $update_user = "UPDATE $db_user_table SET logged_in = '1' WHERE username = '$username'"; //query to check if user is logged in or not $check_user = "SELECT * FROM $db_user_table WHERE logged_in = '1'"; $user_results = mysql_query($check_user); $count_users = mysql_num_rows($user_results); //if users logged in is greater than or equal to 1 if($count_users != 0) { $users_row = mysql_fetch_array($user_results); } //execute the query $results = mysql_query($query); //count the number of rows $count = mysql_num_rows($results); //if the username exists fetch the results if ($count = 1) { $row = mysql_fetch_array($results); } //if username is blank if (empty($username)) { //include header include("includes/header.php"); //include login box include ("includes/login_box.php"); //include news box include("includes/news_box.php"); echo "<br><center>"; echo "Please enter a username!"; echo "</center>"; include("includes/footer.php"); } //if password is blank else if (empty($password)) { //include header include("includes/header.php"); //include login box include ("includes/login_box.php"); //include news box include("includes/news_box.php"); echo "<br><center>"; echo "Please enter a password!"; echo "</center>"; include("includes/footer.php"); } //if username is not in database else if ($username != $row['username']) { //include header include("includes/header.php"); //include login box include ("includes/login_box.php"); //include news box include("includes/news_box.php"); echo "<br><center>"; echo "That username does not exist in our database. Please try again."; echo "</center>"; include("includes/footer.php"); } //if password is not in database else if ($password != $row['password']) { //include header include("includes/header.php"); //include login box include ("includes/login_box.php"); //include news box include("includes/news_box.php"); echo "<br><center>"; echo "The password you have entered is incorrect. Please try again."; echo "</center>"; include("includes/footer.php"); } //if someone is already logged in with the ip address else if($num_ip == 1) { //include header include("includes/header.php"); //include login box include ("includes/login_box.php"); //include news box include("includes/news_box.php"); echo "<br><center>"; echo "Someone is already logged in with that IP ADDRESS."; echo "</center>"; include("includes/footer.php"); } else if($username == $users_row['username']) { //include header include("includes/header.php"); //include login box include ("includes/login_box.php"); //include news box include("includes/news_box.php"); echo "<br><center>"; echo "Someone is already logged in with that username."; echo "</center>"; include("includes/footer.php"); } //if everything is ok register the username in the session and redirect to logged_in.php else { $update_ip = mysql_query($update_query) or die("Could not enter information!"); $update_user_logged_in = mysql_query($update_user); session_start(); $_SESSION['logged_in'] = TRUE; $_SESSION['username'] = $username; header("Location:logged_in.php"); } ?> The problem is that if I log in as the first user in the database it works but any other user it doesnt. Any help is appreciated. Thanks in advance
  25. I tried doing that but it goes to the last part of the text. It does not put it right above the bottom border.
×
×
  • 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.