ccrevcypsys Posted January 2, 2008 Share Posted January 2, 2008 so heres what i have and it doesnt work how i want it to ( i want it so that when someone tries to login and there is already a session i will have it update the information in the db with the new sess data and the new times instead of making 1.3 billion of them over the course of the next 2 weeks lol. so if you can help it would be awsome ) <?php if($_POST['email']==TRUE){ //Check if already logged in $query = "SELECT * FROM `sessions`"; $result = mysql_query($query)or die(mysql_error()."error 1"); $row = mysql_fetch_array($result, MYSQL_ASSOC)or die(mysql_error()."error 3"); if($row == TRUE && $row['customer_id']=="36"){ echo "Already Logged In Click Here To Destroy All Sessions."; }else{ $querys = "SELECT * FROM customer WHERE email = '".$_POST['email']."' AND password='".$_POST['password']."'"; $results = mysql_query($querys)or die(mysql_error()."error 1"); $rows = mysql_fetch_array($results, MYSQL_ASSOC)or die(mysql_error()."error 2"); $login = $_POST['email']; if($rows){ $sessId = rand(50,1000); $insert = mysql_query("INSERT INTO sessions (sessId,customer_id,timeStart,timeLast) VALUES (".$sessId.",".$rows['customer_id'].", ".date('his').",".date('his').")")or die(mysql_error()); if($insert==TRUE){ setcookie("sessId", $sessId, time()+3600); setcookie("customer_id", $rows['customer_id'], time()+3600); header("Location: index.php?p=V"); } } } } ?> Quote Link to comment https://forums.phpfreaks.com/topic/84182-one-login-at-a-time-help-plz/ Share on other sites More sharing options...
neilfurry Posted January 3, 2008 Share Posted January 3, 2008 you can make use of UPDATE instead of INSERT, eg: if data exists you will make use of UPDATE, INSERT otherwise. put it into a conditional statement Quote Link to comment https://forums.phpfreaks.com/topic/84182-one-login-at-a-time-help-plz/#findComment-428841 Share on other sites More sharing options...
priti Posted January 3, 2008 Share Posted January 3, 2008 Hello, My views are little different. 1.When user log in try to fetch the session id from your session table.(Note: in your table you might have mapped the userid with session id so it would be easier for you to fetch uerid from username/password nad then mapp it to session_id ) 2.If($sessionid) { code to update the db } else { code to insert in db } hope it helps regards Quote Link to comment https://forums.phpfreaks.com/topic/84182-one-login-at-a-time-help-plz/#findComment-429032 Share on other sites More sharing options...
ccrevcypsys Posted January 3, 2008 Author Share Posted January 3, 2008 good point. I feel very dumb for not thinking about that. haha wat a n00bish thing to ask. thnx Quote Link to comment https://forums.phpfreaks.com/topic/84182-one-login-at-a-time-help-plz/#findComment-429477 Share on other sites More sharing options...
priti Posted January 7, 2008 Share Posted January 7, 2008 At times it happen when developers over code anything :-) anywayz glad to help you. Have a gr8 day. Quote Link to comment https://forums.phpfreaks.com/topic/84182-one-login-at-a-time-help-plz/#findComment-432421 Share on other sites More sharing options...
rameshfaj Posted January 7, 2008 Share Posted January 7, 2008 Checking session in that way will help you preventing from direct access of the pages(without logging). Are u trying to implement that login with same ID only for one user? i.e. one ID one login at the same time? Quote Link to comment https://forums.phpfreaks.com/topic/84182-one-login-at-a-time-help-plz/#findComment-432448 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.