Forgot Password / Register
Site Statistics
Total Members: 520
Total Tutorials: 242
Newsest User: 8884244477
Todays Unique Hits: 316
1 Users 9 Guests Online
Forum Index » PHP + MySQL » Newest and total members
Posted on Wednesday 4th July 2007 at 09:09 PM
dtnet
templates/default/images/noavatar.png's Avatar
Active Member
When I log out, and press ctrl + r (f5), the "total members" says that there are 2 members at the site. But, that second person is actually the first member that have ever registered, its just a copy. Thats happend all the time. When I'm logging out the stat are adding one more member (again only a copy of the 1. member.)

logout.php
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<?php 
session_start
(); //allows session 
include "config.php"
echo 
"<center>"
//checks there trying to logout 
if(isset($_GET['logout'])){ 
//deletes the sessions 
unset($_SESSION['id']); 
unset(
$_SESSION['password']); 
//loggedout message 
echo "You are now logged out."

echo 
"<center>"
?>


online.php
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
<?php 
include("config.php"); 

//Query database & Counts the rows in the members database 
$count mysql_num_rows(mysql_query('SELECT * FROM `members`')); 

echo 
$count//Displays the total members 

$new mysql_fetch_array(mysql_query("SELECT * FROM `members` ORDER BY `id` DESC LIMIT 0, 1")); //Gets the newest member 
echo "Newest User: " $new[username]; //Displays the newest member 
?>
Posted on Wednesday 4th July 2007 at 10:41 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
Can you explain your problem a it more
Posted on Thursday 5th July 2007 at 09:50 AM
dtnet
templates/default/images/noavatar.png's Avatar
Active Member
sure.

http://henrik.hotserv.dk/members.php

As you can see in the link, there are many members with the same name. But, if you click on one of them, you can see that they are all the same member.

I can log in and out without problems. But when I log out, the memberlist is adding a new copy of the member. It's also adding the new member in the database.

Now, I saw that when I log in, the memberlist is adding a new copy of the member that I log in with.
Posted on Thursday 5th July 2007 at 09:39 PM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
It must be your login code? post it?
Posted on Saturday 7th July 2007 at 08:35 PM
dtnet
templates/default/images/noavatar.png's Avatar
Active Member
PHP Code
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
<?php 
session_start
();
require_once 
"config.php"
if(
$logged[id]){ 
echo 
"<h3>Velkommen $logged[username]</h3>"
echo 

<div><a href='editprofile.php'>Endre Profil</a><br> 
<a href='changepassword.php'>Bytt Passord</a><br>
<a href='members.php'>Medlemmer</a><br>
<a href='logout.php?logout'>Logg ut</a></div>"


else 
//if there trying to login 
if(isset($_GET['login'])){ 
$usernamehtmlspecialchars(addslashes($_POST[username]));  
$password sha1(md5(md5(sha1(md5(sha1(sha1(md5($_POST[password])))))))); 
$uinfo mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());  
$checkuser mysql_num_rows($uinfo); 
if(
$checkuser == '0'

echo 
"Brukernavn ikke funnet"

else 

$udata mysql_fetch_array($uinfo); 
if(
$udata[userlevel] == 1) {  
echo 
"This account had not been verified."

else 
if(
$udata[password] == $password) { 
$query mysql_query("SELECT * FROM `members` WHERE `username` = '$username'") or die(mysql_error());  
$user mysql_fetch_array($query); 
//sets the logged session 
$_SESSION['id'] = "$user[id]"
$_SESSION['password'] = "$user[password]";
$online mysql_query("INSERT INTO `members` (`username`, `online`) VALUES('$username','1')"); 

echo 
"You are now logged in, Please wait. . ."
echo 
"<meta http-equiv='Refresh' content='2; URL=index.php'/>"

else 

echo 
"Incorrect username or password!";  



else 

//If not the above show the login form 
echo "<form action='login.php?login' method='post'> 
<p>Brukernavn:<input type='text' name='username' />
Passord:<input type='password' name='password' />
<input type='submit' name='login' value='Login' /></p>
Ikke registrert? <a href='register.php'>Klikk her</a>
</form>"


?>
Posted on Sunday 8th July 2007 at 07:58 AM
SkillMaster
templates/default/images/noavatar.png's Avatar
Senior Member
Code

$online = mysql_query("INSERT INTO `members` (`username`, `online`) VALUES('$username','1')");


to

Code

$online = mysql_query("UPDATE `members` SET `online` = '1' WHERE `username` = '$username'");

Enjoy