PHP - Best Way To Show When Users Are Online?
What would the best way be to show when a user is online? Detecting when they close the browser/tab, not just log out?
Similar TutorialsI've seen countless forum software/cms which have such feature, I understand how they count the total users online (as theirs a row which says if a user is online or not (boolean), and then its all counted using mysql_num_rows() to get the total) However I don't get how they'd display the number of Guests? (as I don't think they'd log them woul'dnt that be messy/tedious?) Hello. I have recently been building a user system and trying to code an "Online Users" script for it however it is not working out for me, so I thought I'd come and ask here. I need a script that adds them to the table 'online' when they login and then remove them when they logout. That part is simple to do however I am using sessions and I am trying to figure out a way to check if they are inactive like every 10 minutes, and if they are delete their row from the db. It'd be appreciated if someone could set up a code for this. I looked for a script that shows the number of users online on the site i am making, and found this. I don't know if it is for just showing if the user is online on that one page like a profile page, or if it is for all users in the database. Also, when using the code, it shows "Users Online: 1" then when I reload the page, it says "2' and again, then "3" even though no users have logged in. Thank you. the script Code: [Select] <?php ///////////////////////////////////////////////////////////////////////////////////////// ////IS USER ONLINE SCRIPT PART//// $session=session_id(); $time=time(); $time_check=$time-600; //SET TIME 10 Minute //CONNECT TO DB //connect info here // Connect to server and select databse mysql_connect("$host1", "$username1", "$password1")or die("cannot connect to server"); mysql_select_db("$db_name1")or die("cannot select DB"); $sql="SELECT * FROM $tbl_name1 WHERE session='$session'"; $result=mysql_query($sql)or die(mysql_error()); $count=mysql_num_rows($result); if($count=="0"){ $sql1="INSERT INTO $tbl_name1(session, time)VALUES('$session', '$time')"; $result1=mysql_query($sql1)or die(mysql_error()); } else { "$sql2=UPDATE $tbl_name1 SET time='$time' WHERE session = '$session'"; $result2=mysql_query($sql2)or die(mysql_error()); } $sql3="SELECT * FROM $tbl_name1"; $result3=mysql_query($sql3)or die(mysql_error()); $count_user_online=mysql_num_rows($result3); echo "User online : $count_user_online "; // if over 10 minute, delete session $sql4="DELETE FROM $tbl_name WHERE time<$time_check"; $result4=mysql_query($sql4); mysql_close(); // Open multiple browser page for result ///////////////////////////////////////////////////////////////////////////////////////////// ?> I am trying to display current online registered users and online guests. A user is defined as online by the online column in the database. if set to 1 they are online, if set to 0 they are offline. so when a user logs in i set this column to 1 to show they are online. but when a user is inactive i set it to 0. i do this using: Code: [Select] if($user->last_active_time < time()-1800) { $link->query("UPDATE ".TBL_PREFIX."users SET u_online = 0 WHERE u_username = '".$user->user_name."'") or die(print_link_error()); } else { $link->query("UPDATE ".TBL_PREFIX."users SET u_online = 1 WHERE u_username = '".$user->user_name."'") or die(print_link_error()); } $user->last_active_time is set on every page load to the current time stamp(UNIX) however they are sometimes displayed as online or offline when they arent. Also for displaying guests i use: Code: [Select] $session_time = time()-300; $query = $link->query("SELECT g_ip FROM ".TBL_PREFIX."guests WHERE g_ip = '".$_SERVER['REMOTE_ADDR']."'") or die(print_link_error()); $num_rows = $query->rowCount(); if($num_rows == 0) { if(!$user->user_name) { $link->query("INSERT INTO ".TBL_PREFIX."guests (g_ip, g_time) VALUES ('".$_SERVER['REMOTE_ADDR']."', '".$config['time_now']."')") or die(print_link_error()); } } if the IP address of the current visitor is not in the database and they are not logged in then it adds their ip to the database. but sometimes more guests are displayed then there actually are(tested this on local server so i know how many are online). Are there any better ways i could be doing this? Hi, I'm trying to code a page which displays the amount of users currently viewing a page. But how do I decrease the count if a user closes the page? Thanks The following code is what I have already done, but I have just realised that the way I have done this will not enable me to display the online users in alphabetical order, I do not know a way how to do this. Any help or suggestions? Thanks $friend_query = mysql_query("SELECT * FROM friend_request WHERE user='{$user_id}'"); $friend_id_array = ""; while($row = mysql_fetch_assoc($friend_query)) { $friend_id = $row['friend_id']; $more_query = mysql_query("SELECT * FROM friend_request WHERE friend_id='{$user_id}'"); while($row_more = mysql_fetch_assoc($more_query)) { $more_friend_id = $row_more['user']; //all friends in an array $friend_id_array = $friend_id_array.$friend_id."/".$more_friend_id; $friend_id_array = explode('/', $friend_id_array); $friend_count = count($friend_id_array); //how many of the friends are online $online_count = 0; for($i=0;$i<$friend_count;$i++) { $query_online = mysql_query("SELECT loggedin, fname, mname, lname FROM users WHERE id='{$friend_id_array[$i]}'"); //get loggedin and names $row = mysql_fetch_assoc($query_online); $loggedin = $row['loggedin']; if($loggedin == "1") //if logged in { $online_count++; // final number off people online } } } } Sites such as this one often show the logged on users and guests.
I have no reason to need to do so, but am curious on how this is accomplished.
For users, yes, you've authenticated them and logged them on regardless of IP address, but how do you know they didn't just close their browser?
For guests, are they just using IP address? And still, how do you know when they leave?
PS. How should I include an image in a post like I did? What I did was first attach a file, and then edit the post to include that file as an image. Couldn't seem to include an image off my local PC. Not a better way?
Attached Files
Capture.PNG 4.13KB
0 downloads Hi guys Just wanted to knw whats the php logic needed to create this function which shows current users viewing a topic I knw we can have a database table which stores the topic ID as well as user id and that way we can record who is viewing a topic but what happens when they leave? some users can just close there browser in which case I would never know when they left? thank you guys Hello
I am trying to work out how many regular users I have to my site and how long those users tend to be users..
So, I have a table that logs every time a user visits my site and logs in, it stores the date / time as a unix timestamp and it logs their user id.
I started by getting the id's of any user who logs in more than 5 times in a specified period, but now I want to extend that...
SELECT userID as user, count(userID) as logins FROM login_history where timestamp > UNIX_TIMESTAMP('2014-06-01 00:00:00') and timestamp < UNIX_TIMESTAMP('2014-07-01 00:00:00') group by user having logins > 5; I just discovered that I have a major security flaw with my website. Anyone who logs in to the website can easily access other users information as well as delete and edit other users information just by changing the ID variable in the address bar. I have user ID Session started on these pages but still people can do anything they like with other users information just by editing the address bar. For example if your logged in in the address bar of www.mywebsite.com/delete_mystuff.php?id=5 and change the "5" say to a "9" then you will have access to user#9 information. Every important page that I have has this code: Code: [Select] session_start(); if (!isset($_SESSION['user_id'])) { // Start defining the URL. $url = 'http://' . $_SERVER['HTTP_HOST'] . dirname($_SERVER['PHP_SELF']); // Check for a trailing slash. if ((substr($url, -1) == '/') OR (substr($url, -1) == '\\') ) { $url = substr ($url, 0, -1); // Chop off the slash. } // Add the page. $url .= '/index.php'; ob_end_clean(); // Delete the buffer. header("Location: $url"); exit(); // Quit the script. } else { //Else If Logged In Run The Script if((isset($_GET['id'])) && (is_numeric($_GET['id']))) { $id = (int) $_GET['id']; } elseif ((isset($_POST['id'])) && (is_numeric($_POST['id']))) { $id = (int) $_POST['id']; } else { echo ' No valid ID found, passed in url or form element'; exit(); } What am I doing wrong? Please help if you know how to correct this. Many thanks in advance. I want to show a cookie of a referral's username on a sign up page. The link is like this, www.mysite.com/signup?ref=johnsmith. The cookie doesn't show if I go to that url page. But it does show up once I reload the page. So I'm wondering if it's possible to show the cookie the first time around, instead of reloading the page? Here is my code. // This is in the header $url_ref_name = (!empty($_GET['ref']) ? $_GET['ref'] : null); if(!empty($url_ref_name)) { $number_of_days = 365; $date_of_expiry = time() + 60 * 60 * 24 * $number_of_days; setcookie( "ref", $url_ref_name, $date_of_expiry,"/"); } else if(empty($url_ref_name)) { if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; } } else {} // This is for the sign up form if(isset($_COOKIE['ref'])) { $user_cookie = $_COOKIE['ref']; ?> <fieldset> <label>Referred By</label> <div id="ref-one"><span><?php if(!empty($user_cookie)){echo $user_cookie;} ?></span></div> <input type="hidden" name="ref" value="<?php if(!empty($user_cookie)){echo $user_cookie;} ?>" maxlength="20" placeholder="Referrer's username" readonly onfocus="this.removeAttribute('readonly');" /> </fieldset> <?php }
I am displaying rows from a database onto a page using: while($row=mysql_fetch_array($query)){ echo $row['name']; } I need to figure out how to limit the rows shown to the page to 100. And if there are 100 rows on the page, a link will be displayed at the bottom, that says "Next 100". Then this will display the next 100 rows. Can you give an example how to do this please? Thanks im creating a members website and i want to show how many people are logging, in my database i have a col named online every time somone logs in there online goes from 0 to 1 and when thay log out it goes back to 0. i need to know how to show the total people that have 1 in there online part of the data base iv tryed this code and its not working <?php $result = mysql_query("SELECT online FROM `members` WHERE online='1'"); $row = mysql_fetch_row($result); echo $row; ?> this works in the sql console in phpmyadmin I am quite inexperienced when it comes to coding and I obtained a template for an online form submission that I butchered to meet my needs. Our clients are attempting to send the form, and there are times that it transmits correctly, and times that it won't. There is verification code to try and eliminate bots from filing and submitting bogus forms. Can anyone spend the time to review my code and attempt to tell you where my issue may lie? You may view my form at http://www.damageana..._assignment.php
<?php session_start(); function getRealIp() { if (!empty($_SERVER['HTTP_CLIENT_IP'])) { //check ip from share internet $ip=$_SERVER['HTTP_CLIENT_IP']; } elseif (!empty($_SERVER['HTTP_X_FORWARDED_FOR'])) { //to check ip is pass from proxy $ip=$_SERVER['HTTP_X_FORWARDED_FOR']; } else { $ip=$_SERVER['REMOTE_ADDR']; } return $ip; } function writeLog($where) { $ip = getRealIp(); // Get the IP from superglobal $host = gethostbyaddr($ip); // Try to locate the host of the attack $date = date("d M Y"); // create a logging message with php heredoc syntax $logging = <<<LOG \n << Start of Message >> There was a hacking attempt on your form. \n Date of Attack: {$date} IP-Adress: {$ip} \n Host of Attacker: {$host} Point of Attack: {$where} << End of Message >> LOG; // Awkward but LOG must be flush left // open log file if($handle = fopen('hacklog.log', 'a')) { fputs($handle, $logging); // write the Data to file fclose($handle); // close the file } else { // if first method is not working, for example because of wrong file permissions, email the data $to = 'aserio@damageana.com'; $subject = 'HACK ATTEMPT'; $header = 'From: aserio@damageana.com'; if (mail($to, $subject, $logging, $header)) { echo "Sent notice to admin."; } } } function verifyFormToken($form) { // check if a session is started and a token is transmitted, if not return an error if(!isset($_SESSION[$form.'_token'])) { return false; } // check if the form is sent with token in it if(!isset($_POST['token'])) { return false; } // compare the tokens against each other if they are still the same if ($_SESSION[$form.'_token'] !== $_POST['token']) { return false; } return true; } function generateFormToken($form) { // generate a token from an unique value, took from microtime, you can also use salt-values, other crypting methods... $token = md5(uniqid(microtime(), true)); // Write the generated token to the session variable to check it against the hidden field when the form is sent $_SESSION[$form.'_token'] = $token; return $token; } // VERIFY LEGITIMACY OF TOKEN if (verifyFormToken('form1')) { // CHECK TO SEE IF THIS IS A MAIL POST if (isset($_POST['req-name'])) { // Building a whitelist array with keys which will send through the form, no others would be accepted later on $whitelist = array('token','req-company','req-email','req-name','req-phone','ext','fax','assign_type','loss_type','req-claim','policy','ded','dol','Clmt-Own','insd','insd_add','insd_city','insd_st','insd-zip','insd-home','insd-work','insd-cell','insd-other','clmt','clmt_add','clmt_city','clmt_st','clmt-zip','clmt-home','clmt-work','clmt-cell','clmt-other','VIN','veh-year','veh-make','veh-model','veh-model','veh-color','lic_pl','location','loc-name','loc-add','loc-city','loc-st','loc-zip','loc-con','loc-phone','desc-loss','desc-dmg','spec-inst','save-company','save-email','save-name','save-phone'); // Building an array with the $_POST-superglobal foreach ($_POST as $key=>$item) { // Check if the value $key (fieldname from $_POST) can be found in the whitelisting array, if not, die with a short message to the hacker if (!in_array($key, $whitelist)) { writeLog('Unknown form fields'); die("Hack-Attempt detected. Please use only the fields in the form"); } } // SAVE INFO AS COOKIE, if user wants name and email saved $saveCompany = $_POST['save-company']; if ($saveCompany == 'on') { setcookie("NA-Company", $_POST['req-company'], time()+60*60*24*365); } $saveName = $_POST['save-name']; if ($saveName == 'on') { setcookie("NA-Name", $_POST['req-name'], time()+60*60*24*365); } $saveEmail = $_POST['save-email']; if ($saveEmail =='on') { setcookie("NA-Email", $_POST['req-email'], time()+60*60*24*365); } $savePhone = $_POST['save-phone']; if ($savePhone =='on') { setcookie("NA-Phone", $_POST['req-phone'], time()+60*60*24*365); } // PREPARE THE BODY OF THE MESSAGE $message = '<html><body>'; $message .= '<img src="http://www.damageana.com/images/DANA_NA_header.png" alt="Assignment Request" />'; $message .= '<table rules="all" style="border-color: #666;" cellpadding="10">'; $message .= "<tr style='background: #eee;'><td><strong>Company:</strong> </td><td>" . strip_tags($_POST['req-company']) . "</td></tr>"; $message .= "<tr><td><strong>Adjuster:</strong> </td><td>" . strip_tags($_POST['req-name']) . "</td></tr>"; $message .= "<tr><td><strong>Email:</strong> </td><td>" . strip_tags($_POST['req-email']) . "</td></tr>"; $message .= "<tr><td><strong>Phone:</strong> </td><td>" . strip_tags($_POST['req-phone']) . "</td></tr>"; if($_POST['ext'] !='') {$message .= "<tr><td><strong>Extension:</strong> </td><td>" . strip_tags($_POST['ext']) . "</td></tr>";} if($_POST['fax'] !='') {$message .= "<tr><td><strong>Fax:</strong> </td><td>" . strip_tags($_POST['fax']) . "</td></tr>";} $message .= "<tr><td><strong>Assignment Type:</strong> </td><td>" . strip_tags($_POST['assign_type']) . "</td></tr>"; if($_POST['loss_type'] !='') {$message .= "<tr><td><strong>Type of Loss:</strong> </td><td>" . strip_tags($_POST['loss_type']) . "</td></tr>";} $message .= "<tr><td><strong>Claim #:</strong> </td><td>" . strip_tags($_POST['req-claim']) . "</td></tr>"; if($_POST['policy'] !='') {$message .= "<tr><td><strong>Policy #:</strong> </td><td>" . strip_tags($_POST['policy']) . "</td></tr>";} if($_POST['ded'] !='') {$message .= "<tr><td><strong>Deductible:</strong> </td><td> $" . strip_tags($_POST['ded']) . "</td></tr>";} if($_POST['dol'] !='') {$message .= "<tr><td><strong>Date of Loss:</strong> </td><td>" . strip_tags($_POST['dol']) . "</td></tr>";} if($_POST['insd'] !='') {$message .= "<tr><td><strong>Insured:</strong> </td><td>" . strip_tags($_POST['insd']) . "</td></tr>";} if($_POST['insd_add'] !='') {$message .= "<tr><td><strong>Insured's Address:</strong> </td><td>" . strip_tags($_POST['insd_add']) . "</td></tr>";} if($_POST['insd_city'] !='') {$message .= "<tr><td><strong>Insured's City:</strong> </td><td>" . strip_tags($_POST['insd_city']) . "</td></tr>";} if($_POST['insd_st'] !='') {$message .= "<tr><td><strong>Insured's State:</strong> </td><td>" . strip_tags($_POST['insd_st']) . "</td></tr>";} if($_POST['insd-zip'] !='') {$message .= "<tr><td><strong>Insured's Zip:</strong> </td><td>" . strip_tags($_POST['insd-zip']) . "</td></tr>";} if($_POST['insd-home'] !='') {$message .= "<tr><td><strong>Insured's Home Phone:</strong> </td><td>" . strip_tags($_POST['insd-home']) . "</td></tr>";} if($_POST['insd-work'] !='') {$message .= "<tr><td><strong>Insured's Work Phone:</strong> </td><td>" . strip_tags($_POST['insd-work']) . "</td></tr>";} if($_POST['insd-cell'] !='') {$message .= "<tr><td><strong>Insured's Mobile Phone:</strong> </td><td>" . strip_tags($_POST['insd-cell']) . "</td></tr>";} if($_POST['insd-other'] !='') {$message .= "<tr><td><strong>Insured's Other Phone:</strong> </td><td>" . strip_tags($_POST['insd-other']) . "</td></tr>";} if($_POST['clmt'] !='') {$message .= "<tr><td><strong>Claimant:</strong> </td><td>" . strip_tags($_POST['clmt']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Address:</strong> </td><td>" . strip_tags($_POST['clmt_add']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's City:</strong> </td><td>" . strip_tags($_POST['clmt_city']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's State:</strong> </td><td>" . strip_tags($_POST['clmt_st']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Zip:</strong> </td><td>" . strip_tags($_POST['clmt-zip']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Home Phone:</strong> </td><td>" . strip_tags($_POST['clmt-home']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Work Phone:</strong> </td><td>" . strip_tags($_POST['clmt-work']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Mobile Phone:</strong> </td><td>" . strip_tags($_POST['clmt-cell']) . "</td></tr>"; $message .= "<tr><td><strong>Claimant's Other Phone:</strong> </td><td>" . strip_tags($_POST['clmt-other']) . "</td></tr>";} if($_POST['VIN'] !='') {$message .= "<tr><td><strong>VIN:</strong> </td><td>" . strip_tags($_POST['VIN']) . "</td></tr>";} if($_POST['veh-year'] !='') {$message .= "<tr><td><strong>Year:</strong> </td><td>" . strip_tags($_POST['veh-year']) . "</td></tr>";} if($_POST['veh-make'] !='') {$message .= "<tr><td><strong>Make:</strong> </td><td>" . strip_tags($_POST['veh-make']) . "</td></tr>";} if($_POST['veh-model'] !='') {$message .= "<tr><td><strong>Model:</strong> </td><td>" . strip_tags($_POST['veh-model']) . "</td></tr>";} if($_POST['veh-color'] !='') {$message .= "<tr><td><strong>Color:</strong> </td><td>" . strip_tags($_POST['veh-color']) . "</td></tr>";} if($_POST['lic_pl'] !='') {$message .= "<tr><td><strong>License Plate:</strong> </td><td>" . strip_tags($_POST['lic_pl']) . "</td></tr>";} $message .= "<tr><td><strong>Unit Location:</strong> </td><td>" . strip_tags($_POST['location']) . "</td></tr>"; if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Name:</strong> </td><td>" . strip_tags($_POST['loc-name']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Address:</strong> </td><td>" . strip_tags($_POST['loc-add']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location City:</strong> </td><td>" . strip_tags($_POST['loc-city']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location State:</strong> </td><td>" . strip_tags($_POST['loc-st']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Zip:</strong> </td><td>" . strip_tags($_POST['loc-zip']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Contact:</strong> </td><td>" . strip_tags($_POST['loc-con']) . "</td></tr>";} if($_POST['location'] =='At Another Location') {$message .= "<tr><td><strong>Location Phone:</strong> </td><td>" . strip_tags($_POST['loc-phone']) . "</td></tr>";} if($_POST['desc-loss'] !='') {$message .= "<tr><td><strong>Description of Loss:</strong> </td><td>" . htmlentities($_POST['desc-loss']) . "</td></tr>";} if($_POST['desc-dmg'] !='') {$message .= "<tr><td><strong>Description of Damage:</strong> </td><td>" . htmlentities($_POST['desc-dmg']) . "</td></tr>";} if($_POST['spec-inst'] !='') {$message .= "<tr><td><strong>Special Instructions:</strong> </td><td>" . htmlentities($_POST['spec-inst']) . "</td></tr>";} $message .= "</table>"; $message .= "</body></html>"; // MAKE SURE THE "FROM" EMAIL ADDRESS DOESN'T HAVE ANY NASTY STUFF IN IT $pattern = "/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/i"; if (preg_match($pattern, trim(strip_tags($_POST['req-email'])))) { $cleanedFrom = trim(strip_tags($_POST['req-email'])); } else { return "The email address you entered was invalid. Please try again!"; } // CHANGE THE BELOW VARIABLES TO YOUR NEEDS $to = 'office@damageana.com'; $subject = 'New Assignment Request'; $headers = "From: " . $cleanedFrom . "\r\n"; $headers .= "Reply-To: ". strip_tags($_POST['req-email']) . "\r\n"; $headers .= "MIME-Version: 1.0\r\n"; $headers .= "Content-Type: text/html; charset=ISO-8859-1\r\n"; if (mail($to, $subject, $message, $headers)) { echo 'Your message has been sent.'; } else { echo 'There was a problem sending the email.'; } // DON'T BOTHER CONTINUING TO THE HTML... die(); } } else { if (!isset($_SESSION[$form.'_token'])) { } else { echo "Hack-Attempt detected. Got ya!."; writeLog('Formtoken'); } } ?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="fr" lang="fr"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>New Assignment Request Form</title> <link rel="stylesheet" href="css/jqtransform.css" type="text/css" media="all" /> <link rel="stylesheet" href="css/style.css" type="text/css" media="all" /> <script src="http://www.google.com/jsapi" type="text/javascript"></script> <script type="text/javascript"> google.load("jquery", "1.3.2"); </script> <script type="text/javascript" src="js/jquery.jqtransform.js"></script> <script type="text/javascript" src="js/jquery.validate.js"></script> <script type="text/javascript" src="js/jquery.form.js"></script> <script type="text/javascript" src="js/websitechange.js"></script> </head> <?php // generate a new token for the $_SESSION superglobal and put them in a hidden field $newToken = generateFormToken('form1'); ?> <body> <div id="page-wrap"> <img src="http://www.damageana.com/images/logo.png" alt="DANA_logo" width="750" height="70" /> <h1>New Assignment Request Form</h1> <form action="new_assignment.php" method="post" id="change-form"> <h4>IMPORTANT - PLEASE READ.</h4> <h3> -Please provide us with as much information as possible to aide us in setting up a new appraisal for you. <br> <br> -Please be sure to provide as least one good contact number for the vehicle owner. <br> <br> -Once submitted, you will receive an acknowledgement in your e-mail with information regarding the appraisal for your claim. <br> <br> -If submitted before 3 PM, and no acknowledgement is received by 5 PM, please call our office to confirm we received the request.</h3> <input type="hidden" name="token" value="<?php echo $newToken; ?>"> <div class="rowElem"> <label for="req-company">Company*:</label> <input type="text" id="req-company" name="req-company" class="required" minlength="2" value="<?php echo $_COOKIE["NA-Company"]; ?>" /> </div> <div class="rowElem"> <label for="req-name">Adjuster*:</label> <input type="text" id="req-name" name="req-name" class="required" minlength="2" value="<?php echo $_COOKIE["NA-Name"]; ?>" /> </div> <div class="rowElem"> <label for="req-email">E-mail*:</label> <input type="text" name="req-email" class="required email" value="<?php echo $_COOKIE["NA-Email"]; ?>" /> </div> <div class="rowElem"> <label for="req-phone">Phone*:</label> <input type"text" id="req-phone" name="req-phone" class="required" maxlength="12" value="<?php echo $_COOKIE["NA-Phone"]; ?>" /> </div> <div class="rowElem"> <label for="ext">Extension:</label> <input type="text" id="ext" /> </div> <div class="rowElem"> <label for="fax">Fax:</label> <input type="text" id"fax" /> </div> <h2>Claim Info</h2> <div class="rowElemSelect"> <label for="assign_type">Assignment Type*:</label> <select name="assign_type" class="required"> <option value="Automobile">Automobile</option> <option value="Recreational">Recreational</option> <option value="Heavy Equipment">Heavy Equipment</option> <option value="Property">Minor Property</option> <option value="Estimate Audit">Estimate Audit</option> <option value="Scene Investigation">Scene Investigation</option> <option value="Arbitration">Arbitration</option> <option value="DRP Inspection">DRP Quality Control Inspection</option> <option value="Photos Only">Photos Only</option> </select> </div> <br> <div class"rowElemSelect"> <label for="loss_type">Type of Loss:</label> <select name="loss_type" id="loss_type"> <option value="Collision">Collision</option> <option value="Comprehensive">Comprehensive</option> <option value="Other">Other</option> </select> </div> <div class="rowElem"> <label for="req-claim">Claim #*:</label> <input type="text" id="req-claim" name="req-claim" class="required"> </div> <div class="rowElem"> <label for"policy">Policy #:</label> <input type="text" id="policy" name="policy"> </div> <div class="rowElem"> <label for="ded">Deductible:</label> <input type="text" id="ded" name="ded"> </div> <div class="rowElem"> <label for="dol">Date of Loss:</label> <input type="date" id="dol" name="dol"> </div> <div class="rowElem"> <label for="Clmt-Own">Claimant Vehicle?</label> <input type="checkbox" name="Clmt-Own" id="ClmtCheck" /> </div> <h2>Insured Info</h2> <div class="rowElem"> <label for="insd">Insured:</label> <input type="text" id="insd" name="insd"> </div> <div class ="rowElem"> <label for="insd_add">Address:</label> <input type="text" id="insd_add" name="insd_add"> </div> <div class="rowElem"> <label for="insd_city">City:</label> <input type="text" id="insd_city" name="insd_city"> </div> <br> <div class="rowElem"> <label for="insd_st">State:</label> <select name="insd_st" id="insd_st"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI" selected="selected">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> </div> <div class="rowElem"> <label for="insd-zip">Zip Code:</label> <input type="text" name="insd-zip" id="insd-zip" minlength="5" maxlength="10"> </div> <div class="rowElem"> <label for="insd-home">Home Phone:</label> <input type="text" name="insd-home" id="insd-home" maxlength="12"> </div> <div class="rowElem"> <label for="insd-work">Work Phone:</label> <input type="text" name="insd-work" id="insd-work" maxlength="12"> </div> <div class="rowElem"> <label for="insd-cell">Mobile Phone:</label> <input type="text" name="insd-cell" id="insd-cell" maxlength="12"> </div> <div class="rowElem"> <label for="insd-other">Other Phone:</label> <input type="text" name="insd-other" id="insd-other" maxlength="12"> </div> <br> <div id="Clmt-Info"> <h2>Claimant Info</h2> <div class="rowElem"> <label for="clmt">Claimant:</label> <input type="text" id="clmt" name="clmt"> </div> <div class ="rowElem"> <label for="clmt_add">Address:</label> <input type="text" id="clmt_add" name="clmt_add"> </div> <div class="rowElem"> <label for="clmt_city">City:</label> <input type="text" id="clmt_city" name="clmt_city"> </div> <br> <div class="rowElem"> <label for="clmt_st">State:</label> <select name="clmt_st" id="clmt_st"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI" selected="selected">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> </div> <div class="rowElem"> <label for="clmt-zip">Zip Code:</label> <input type="text" name="clmt-zip" id="clmt-zip" minlength="5" maxlength="10"> </div> <div class="rowElem"> <label for="clmt-home">Home Phone:</label> <input type="text" name="clmt-home" id="clmt-home" maxlength="12"> </div> <div class="rowElem"> <label for="clmt-work">Work Phone:</label> <input type="text" name="clmt-work" id="clmt-work" maxlength="12"> </div> <div class="rowElem"> <label for="clmt-cell">Mobile Phone:</label> <input type="text" name="clmt-cell" id="clmt-cell" maxlength="12"> </div> <div class="rowElem"> <label for="clmt-other">Other Phone:</label> <input type="text" name="clmt-other" id="clmt-other" maxlength="12"> </div> </div> <br> <h2>Damaged Unit Information</h2> <div class="rowElem"> <label for="VIN">VIN:</label> <input type="text" name="VIN" id="VIN" maxlength="17"> </div> <div class="rowElem"> <label for="veh-year">Year:</label> <input type="text" name="veh-year" id="veh-year" maxlength="4"> </div> <div class="rowElem"> <label for="veh-make">Make:</label> <input type="text" name="veh-make" id="veh-make"> </div> <div class="rowElem"> <label for="veh-model">Model:</label> <input type="text" name="veh-model" id="veh-model"> </div> <div class="rowElem"> <label for="lic_pl">License Plate:</label> <input type="text" name="lic_pl" id"lic_pl"> </div> <div class="rowElem"> <label for="veh-color">Color:</label> <input type="text" name="veh-color" id="veh-color"> </div> <div class="rowElem"> <label>Unit Location:</label> <div id="changeLocation"> <input type="radio" name="location" id="owner" value="With the Owner" checked="checked" /> <label for="owner">With the Owner</label> <div class="clear"></div> <label></label> <input type="radio" name="location" id="alt-loc" name="loc" value="At Another Location" /> <label for="alt-loc">At Another Location (i.e. Body Shop, Tow Yard, Workplace)</label> </div> </div> <br> <div class="clear"></div> <br> <br> <div id="loc-info"> <div class="rowElem"> <label for="loc-name">Location Name:</label> <input type="text" name="loc-name" id="loc-name"> </div> <div class="rowElem"> <label for="loc-add">Location Address:</label> <input type="text" name="loc-add" id="loc-add"> </div> <div class="rowElem"> <label for="loc-city">Location City:</label> <input type="text" name="loc-city" id="loc-city"> </div> <div class="rowElem"> <label for="loc-st">State:</label> <select name="loc-st" id="loc-st"> <option value="AL">AL</option> <option value="AK">AK</option> <option value="AZ">AZ</option> <option value="AR">AR</option> <option value="CA">CA</option> <option value="CO">CO</option> <option value="CT">CT</option> <option value="DE">DE</option> <option value="FL">FL</option> <option value="GA">GA</option> <option value="HI">HI</option> <option value="ID">ID</option> <option value="IL">IL</option> <option value="IN">IN</option> <option value="IA">IA</option> <option value="KS">KS</option> <option value="KY">KY</option> <option value="LA">LA</option> <option value="ME">ME</option> <option value="MD">MD</option> <option value="MA">MA</option> <option value="MI" selected="selected">MI</option> <option value="MN">MN</option> <option value="MS">MS</option> <option value="MO">MO</option> <option value="MT">MT</option> <option value="NE">NE</option> <option value="NV">NV</option> <option value="NH">NH</option> <option value="NJ">NJ</option> <option value="NM">NM</option> <option value="NY">NY</option> <option value="NC">NC</option> <option value="ND">ND</option> <option value="OH">OH</option> <option value="OK">OK</option> <option value="OR">OR</option> <option value="PA">PA</option> <option value="RI">RI</option> <option value="SC">SC</option> <option value="SD">SD</option> <option value="TN">TN</option> <option value="TX">TX</option> <option value="UT">UT</option> <option value="VT">VT</option> <option value="VA">VA</option> <option value="WA">WA</option> <option value="WV">WV</option> <option value="WI">WI</option> <option value="WY">WY</option> </select> </div> <div class="rowElem"> <label for="loc-zip">Location Zip:</label> <input type="text" name="loc-zip" id="loc-zip" minlength="5" maxlength="10"> </div> <div class="rowElem"> <label for="loc-con">Location Contact:</label> <input type="text" name="loc-con" id="loc-con"> </div> <div class="rowElem"> <label for="loc-phone">Location Phone:</label> <input type="text" name="loc-phone" id="loc-phone" maxlength="12"> </div> </div> <br> <div class="rowElem"> <label for="desc-loss">Description of Loss:</label> <textarea cols="40" rows="8" name="desc-loss"></textarea> </div> <div class="rowElem"> <label for="desc-dmg">Description of Damage:</label> <textarea cols="40" rows="8" name="desc-dmg"></textarea> </div> <div class="rowElem"> <label for="spec-inst">Special Instructions:</label> <textarea cols="40" rows="8" name="spec-inst"></textarea> </div> <div class="rowElem"> <label> </label> <input type="submit" value="Submit Request" /> </div> <div class="rowElem"> <label> </label> <input type="reset" value="Reset" /> </div> <div id="rowElem"> <label>Click to Save:</label> <input type="checkbox" name="save-company" /> <label for="save-company">Company Name</label> </div> <div class="clear"></div> <div id="rowElem"> <label> </label> <input type="checkbox" name="save-name" /> <label for="save-name">Adjuster's Name</label> </div> <div class="clear"></div> <div id="rowElem"> <label> </label> <input type="checkbox" name="save-email" /> <label for="save-email">Adjuster's E-mail</label> </div> <div class="clear"></div> <div id="rowElem"> <label> </label> <input type="checkbox" name="save-phone" /> <label for="save-phone">Adjuster's Phone</label> </div> </form> </div> <script type="text/javascript"> var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www."); document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E")); </script> <script type="text/javascript"> var pageTracker = _gat._getTracker("UA-68528-29"); pageTracker._initData(); pageTracker._trackPageview(); </script> </body> </html> im trying to count and display the number on users on my site this is the coding im using cant see where im going wrong, its inserted into the data base correctly but wont delete after 60 seconds, cheers matt $session=session_id(); $time=time(); $time_check=$time-60; $sql="SELECT * FROM onlineusers WHERE session='$session'"; $result=mysql_query($sql); $count=mysql_num_rows($result); if($count=="0"){ $sql1="INSERT INTO onlineusers(session, time, username)VALUES('$session', '$time', '$username')"; $result1=mysql_query($sql1); } else { "$sql2=UPDATE onlineusers SET time='$time' WHERE session = '$session'"; $result2=mysql_query($sql2); } $sql3="SELECT * FROM onlineusers"; $result3=mysql_query($sql3); $count_user_online=mysql_num_rows($result3); $sql4="DELETE FROM onlineusers WHERE time<$time_check"; $result4=mysql_query($sql4); And we're back online... again! It may have taken 3-4 days, but we're back.
ok i want to make it to where when you look at there profile it will tell you if they are online or not! how would i do that ? here is my php script that has some modifications on the profile page but wont show if other users are online! here is the login script where i put the session and the profile page. login.php Code: [Select] <?php // Start Session to enable creating the session variables below when they log in session_start(); // Force script errors and warnings to show on page in case php.ini file is set to not display them error_reporting(E_ALL); ini_set('display_errors', '1'); //----------------------------------------------------------------------------------------------------------------------------------- // Initialize some vars $errorMsg = ''; $email = ''; $pass = ''; $remember = ''; if (isset($_POST['email'])) { $email = $_POST['email']; $pass = $_POST['pass']; if (isset($_POST['remember'])) { $remember = $_POST['remember']; } $email = stripslashes($email); $pass = stripslashes($pass); $email = strip_tags($email); $pass = strip_tags($pass); // error handling conditional checks go here if ((!$email) || (!$pass)) { $errorMsg = '<font color="red">Please fill in both fields</font>'; } else { // Error handling is complete so process the info if no errors include 'scripts/connect_to_mysql.php'; // Connect to the database $email = mysql_real_escape_string($email); // After we connect, we secure the string before adding to query //$pass = mysql_real_escape_string($pass); // After we connect, we secure the string before adding to query $pass = md5($pass); // Add MD5 Hash to the password variable they supplied after filtering it // Make the SQL query $sql = mysql_query("SELECT * FROM myMembers WHERE email='$email' AND password='$pass' AND email_activated='1'"); $login_check = mysql_num_rows($sql); // If login check number is greater than 0 (meaning they do exist and are activated) if($login_check > 0){ while($row = mysql_fetch_array($sql)){ // Pleae note: Adam removed all of the session_register() functions cuz they were deprecated and // he made the scripts to where they operate universally the same on all modern PHP versions(PHP 4.0 thru 5.3+) // Create session var for their raw id $id = $row["id"]; $_SESSION['id'] = $id; // Create the idx session var $_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$id"); // Create session var for their username $username = $row["username"]; $_SESSION['username'] = $username; //THIS IS WHERE I EDITED THE SESSION TO SAY IF THERE LOGGED IN OR NOT $logedin = $row['id']; $_SESSION['islogedin']=$logedin; mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$id' LIMIT 1"); // THIS WAS JUST A TEST BUT WONT UPDATE UNTILL THEY LOGOUT mysql_query("UPDATE myMembers SET online='online' WHERE id='$id' LIMIT 1"); } // close while // Remember Me Section if($remember == "yes"){ $encryptedID = base64_encode("g4enm2c0c4y3dn3727553$id"); setcookie("idCookie", $encryptedID, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days setcookie("passCookie", $pass, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days } // All good they are logged in, send them to homepage then exit script header("location: home.php?test=$id"); exit(); } else { // Run this code if login_check is equal to 0 meaning they do not exist $errorMsg = "<h3><font color='red'>Email/Password invalid<br /></font></h3><a href='forgot_pass.php'>Forgot password?</a><div align='right'> <br> Forget to activate you account?</div>"; } } // Close else after error checks } //Close if (isset ($_POST['uname'])){ ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="icon" href="favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link href="style/main.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.4.2.js" type="text/javascript"></script> <title>Log In</title> <title>Login Page</title> <style type="text/css"> #stage { top: 0px; left: 0px; z-index: 100; } .stage { position: absolute; top: 0; left: 0; width: 100%; min-width: 900px; height: 1359px; overflow: hidden; } #bg { background: #aedfe5 url(images/sky1.png) 0 0 repeat-x; } #clouds { background: transparent url(images/cloud.png) 305px 10px repeat-x; } #sun { background: url(images/land_sun.gif)0 0 no-repeat; } #hillbottom { background: url(images/hill2.png)0 1270px repeat-x; } </style> <link rel="stylesheet" type="text/css" href="css/loginstyle.css" /></head> <body> <!-- IE6 fixes are found in styles/ie6.css --> <!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/ie6.css" /><![endif]--> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="js/jquery-ui-1.7.2.spritely.custom.min.js" type="text/javascript"></script> <script src="js/jquery.spritely-0.5.js" type="text/javascript"></script> <script type="text/javascript"> (function($) { $(document).ready(function() { var direction = 'left'; $('#clouds').pan({fps: 40, speed: 0.5, dir: direction, depth: 10}); }); })(jQuery); </script><div id="bg" class="stage"></div> <div id="container"> <div id="sun" class="stage"></div> <div id="clouds" class="stage"> <div id="stage" class="stage"> <body> <div id="behindform"> <form id="signinform" action="login.php" method="post" enctype="multipart/form-data" name="signinform"> <fieldset> <legend>Log in</legend> <label for="login">Email</label> <input type="text" id="email" name="email" /> <div class="clear"></div> <label for="password">Password</label> <input type="password" id="password" name="pass" /> <div class="clear"></div> <label for="remember_me" style="padding: 0;">Remember me?</label> <input type="checkbox" id="remember" style="position: relative; top: 3px; margin: 0; " name="remember"/ value="yes" checked="checked"> <div class="clear"></div> <br /> <input type="submit" style="margin: -20px 0 0 287px;" class="button" name="commit" value="Sign In"/> </fieldset><?php print "$errorMsg"; ?> </form> </div> </div> </div><div id="hillbottom" class="stage"> </div> </body> </html> profile.php This is only a part where i try. but when i putt it on , it wont echo the other peoples on , like it doesnt get the other sessions or somethig Code: [Select] //HERE IS WHERE I STARTED , BUT dONT KNOW WHAT TO DO ! if (isset($_SESSION['islogedin']) && $logOptions_id != $id) { $isonline = "<font color='green'>online</font>"; } else{ $isonline = "<font color='red'>offline</font>"; } // This is to Check if user is online or not! needs editing //$isonline = mysql_query("SELECT online FROM myMembers WHERE id='$logOptions_id'AND online='online'"); //$isonlinecheck=mysql_query($isonline); //if ($isonlinecheck ="online"){ //$online = "is <font color='green'>online!</font>";} //else { // $online = "is<font color='red'> offline!</font>"; //} // End to Check if user is online or not! ?> i got my user login and register working with my sql but now if a non logged in user tries to access the shoutbox i want it to redirect them to the register page. <?PHP session_start(); if (!(isset($_SESSION['login']) && $_SESSION['login'] != '')) { header ("Location: /login/main.php"); } ?> im using that code but even if im logged in, it redirects me to the register page? my main site is on the root of the site. the login page and the logged in page is in "/login/ it displays is online no matter what! please help me! here is the login.php where the session is started . login.php Code: [Select] <?php // Start Session to enable creating the session variables below when they log in session_start(); // Force script errors and warnings to show on page in case php.ini file is set to not display them error_reporting(E_ALL); ini_set('display_errors', '1'); //----------------------------------------------------------------------------------------------------------------------------------- include 'scripts/connect_to_mysql.php'; // Connect to the database // Initialize some vars $errorMsg = ''; $email = ''; $pass = ''; $remember = ''; if (isset($_POST['email'])) { $email = $_POST['email']; $pass = $_POST['pass']; if (isset($_POST['remember'])) { $remember = $_POST['remember']; } $email = stripslashes($email); $pass = stripslashes($pass); $email = strip_tags($email); $pass = strip_tags($pass); // error handling conditional checks go here if ((!$email) || (!$pass)) { $errorMsg = '<font color="red">Please fill in both fields</font>'; } else { // Error handling is complete so process the info if no errors $email = mysql_real_escape_string($email); // After we connect, we secure the string before adding to query //$pass = mysql_real_escape_string($pass); // After we connect, we secure the string before adding to query $pass = md5($pass); // Add MD5 Hash to the password variable they supplied after filtering it // Make the SQL query $sql = mysql_query("SELECT * FROM myMembers WHERE email='$email' AND password='$pass' AND email_activated='1'"); $login_check = mysql_num_rows($sql); // If login check number is greater than 0 (meaning they do exist and are activated) if($login_check > 0){ while($row = mysql_fetch_array($sql)){ // Pleae note: Adam removed all of the session_register() functions cuz they were deprecated and // he made the scripts to where they operate universally the same on all modern PHP versions(PHP 4.0 thru 5.3+) // Create session var for their raw id $id = $row["id"]; $_SESSION['id'] = $id; // Create the idx session var $_SESSION['idx'] = base64_encode("g4p3h9xfn8sq03hs2234$id"); // Create session var for their username $username = $row["username"]; $_SESSION['username'] = $username; //THIS IS WHERE I EDITED THE SESSION TO SAY IF THERE LOGGED IN OR NOT $_SESSION['logedin'] = $_POST['email']; mysql_query("UPDATE myMembers SET last_activity=now() WHERE id='$id'"); mysql_query("UPDATE myMembers SET last_log_date=now() WHERE id='$id' LIMIT 1"); // THIS WAS JUST A TEST BUT WONT UPDATE UNTILL THEY LOGOUT } // close while // Remember Me Section if($remember == "yes"){ $encryptedID = base64_encode("g4enm2c0c4y3dn3727553$id"); setcookie("idCookie", $encryptedID, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days setcookie("passCookie", $pass, time()+60*60*24*100, "/"); // Cookie set to expire in about 30 days } // All good they are logged in, send them to homepage then exit script header("location: /socialtscripts/home.php?test=$id"); exit(); } else { // Run this code if login_check is equal to 0 meaning they do not exist $errorMsg = "<h3><font color='red'>Email/Password invalid<br /></font></h3><a href='forgot_pass.php'>Forgot password?</a><div align='right'> <br> Forget to activate you account?</div>"; } } // Close else after error checks } //Close if (isset ($_POST['uname'])){ ?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <link rel="icon" href="favicon.ico" type="image/x-icon" /> <link rel="shortcut icon" href="favicon.ico" type="image/x-icon" /> <link href="style/main.css" rel="stylesheet" type="text/css" /> <script src="js/jquery-1.4.2.js" type="text/javascript"></script> <title>Log In</title> <title>Login Page</title> <style type="text/css"> #stage { top: 0px; left: 0px; z-index: 100; } .stage { position: absolute; top: 0; left: 0; width: 100%; min-width: 900px; height: 1359px; overflow: hidden; } #bg { background: #aedfe5 url(images/sky1.png) 0 0 repeat-x; } #clouds { background: transparent url(images/cloud.png) 305px 10px repeat-x; } #sun { background: url(images/land_sun.gif)0 0 no-repeat; } #hillbottom { background: url(images/hill2.png)0 1270px repeat-x; } </style> <link rel="stylesheet" type="text/css" href="css/loginstyle.css" /></head> <body> <!-- IE6 fixes are found in styles/ie6.css --> <!--[if lte IE 6]><link rel="stylesheet" type="text/css" href="css/ie6.css" /><![endif]--> <script src="js/jquery-1.3.2.min.js" type="text/javascript"></script> <script src="js/jquery-ui-1.7.2.spritely.custom.min.js" type="text/javascript"></script> <script src="js/jquery.spritely-0.5.js" type="text/javascript"></script> <script type="text/javascript"> (function($) { $(document).ready(function() { var direction = 'left'; $('#clouds').pan({fps: 40, speed: 0.5, dir: direction, depth: 10}); }); })(jQuery); </script><div id="bg" class="stage"></div> <div id="container"> <div id="sun" class="stage"></div> <div id="clouds" class="stage"> <div id="stage" class="stage"> <body> <div id="behindform"> <form id="signinform" action="login.php" method="post" enctype="multipart/form-data" name="signinform"> <fieldset> <legend>Log in</legend> <label for="login">Email</label> <input type="text" id="email" name="email" /> <div class="clear"></div> <label for="password">Password</label> <input type="password" id="password" name="pass" /> <div class="clear"></div> <label for="remember_me" style="padding: 0;">Remember me?</label> <input type="checkbox" id="remember" style="position: relative; top: 3px; margin: 0; " name="remember"/ value="yes" checked="checked"> <div class="clear"></div> <br /> <input type="submit" style="margin: -20px 0 0 287px;" class="button" name="commit" value="Sign In"/> </fieldset><?php print "$errorMsg"; ?> </form> </div> </div> </div><div id="hillbottom" class="stage"> </div> </body> </html>and then this is the profile.php where i see if there online , i could only put sertian areas , script is too big profile.php Code: [Select] <?php //on top of the page where it checks the session and updates the time // This updates the database correctly if( isset($_SESSION['logedin']) ) { mysql_query("UPDATE myMembers SET last_activity=now() WHERE id='$logOptions_id'"); // this is where it selects the users id but it wont work , it says online for every user! $age= 60; if( isset($_SESSION['logedin']) ) { $q = mysql_query('SELECT id=`$logOptions_id`, DATE_FORMAT(`last_activity`,"%a, %b %e %T") as `last_activity`,UNIX_TIMESTAMP(`last_activity`) as `last_activity_stamp`FROM `mymembers`WHERE `$logOptions_id` <> "'.($_SESSION['logedin']).'"'); $isonlinecheck = mysql_query($q); if ($isonlinecheck ="last_activity_stamp" + $age < time()){ $isonline = "is <font color='green'>online!</font>";} else { $online = "is<font color='red'> offline!</font>"; } } ?> PLEASE HELP ME ok well i have this is online script that starts at the login page where it sets a session. well it echos that that person is online even if they are not, i will have all of the code only for the online script so it will be in peaces. ok so here is the login page where the session is started login.php Code: [Select] <?php //ok so if they submit the page and its all right and they login , here is the session that is set for the person, again its just the piece of the script . $_SESSION['logedin'] = $_POST['email']; mysql_query("UPDATE myMembers SET last_activity=now() WHERE id='$id'"); ?> now here is where i call on the session and see if there online , the profile.php is set up to where it sees if it is your profile or not so $logoptions_id is the id that they are logged in as. profile.php Code: [Select] <?php // this is on top of the page , where the session is called and if they are logged in it updates the database where there id is. if( isset($_SESSION['logedin']) ) { mysql_query("UPDATE myMembers SET last_activity=now() WHERE id='$logOptions_id'");// there is where $logOptions_id comes in. } // now this is further down the page(script) where we see if they are logged in or not. $age= 60; //set a variable called age, assign an integer of 60 to it. if( isset($_SESSION['logedin']) ) { $q = 'SELECT id=`$id`, DATE_FORMAT(`last_activity`,"%a, %b %e %T") as `last_activity`,UNIX_TIMESTAMP(`last_activity`) as `last_activity_stamp`FROM `mymembers`WHERE `$id` <> \''.($_SESSION['logedin']).'\''; $isonlinecheck = mysql_query($q); $row = mysql_fetch_assoc($isonlinecheck); if (($row['last_activity_stamp'] + $age)< time()){ $isonline = "is <font color='green'>online!</font>";} else { $isonline = "is<font color='red'> offline!</font>"; } } ?> i wana thank all who helps! your all greatly appreciated |