Jump to content
php.lv forumi

Par IP Adresēm


Mikijs

Recommended Posts

Es nezinu kapēc, bet man notiek kkas šāds..

 

Kad nospiez login un kad ir pareizi user un pwd notiek shis

  $make_login=true;
 if(mysql_num_rows(mysql_query("select name from sys_user_settings where ip='".$_SERVER["REMOTE_ADDR"]."'"))) {
$array=mysql_fetch_array(mysql_query("select * from sys_user_settings where ip='".$_SERVER["REMOTE_ADDR"]."'"));
$time=$array['time'];
$ip=$array['ip'];
$name=$array['name'];
if($ip==$_SERVER["REMOTE_ADDR"]) $make_login="maybe";
if($time>time()&&$make_login=="maybe") $make_login=false;
 }
 if($make_login) {

 login_form();
 login_if_post();
 $post=login_if_post(1);

 if($post=="ok"){
	$time=time()+3600;
	set_cookie ('current_usr', $usr, 0, '/');
	set_cookie ('current_pwd', md5($pwd), 0, '/');
	if(mysql_num_rows(mysql_query("select ip from sys_user_settings where user='$usr'"))) mysql_query("delete from sys_user_settings where user='$usr'");
	mysql_query("insert into sys_user_settings (ip,name,time) values('".$_SERVER["REMOTE_ADDR"]."','$usr','$time')");
  }

 

un sadi izskatas SQL

2 Rows
- - - 1 Row
IP: 127.0.0.1
Name: User
Time:1224062620
- - - 2 Row
IP : 192.168.100.193
Name: User
Time:1224062640

Tagad esmu bik apmulsis jo vinjs izveido 2 Rowsu..

 

kapec vinjs panjem lokalo adresi un pec tam to manu tipa

 

EDIT: piedevām viņš prasa login 2x.

Edited by Mikijs
Link to comment
Share on other sites

Dīvains tev kods. Kāpēc taisi select'tu divas reizes - vienreiz lai nosakidrotu ierakstu skaitu, un otreiz lai izvilktu ieraksta datus? Var jau tak vilkt uzreiz datus, ja to nebūs, tad nekas arī neatnāks.

Un tavs insert's arī dīvains. Par update neesi dzirdējis? Mysql'am ir arī tāds insert on duplicate key, kurš apvieno insert un update darbību vienā kverijā.

Link to comment
Share on other sites

×
×
  • Create New...