Autor Zpráva
Doom4
Profil *
Dobry den chtel bych se zeptat jak osetrit tento formular pro zadavani jmen http://xchatteplice.wz.cz/online.php protoze jakmile uzivatel da refresh browseru nebo se pokusim zadat 2x stejne jmeno automaticky se pocet toho jmena znasobíí :-( nevite jak to osetrit aby se mohlo zadat jen jedno jmeno ? Vse se vypisuje z databaze takze se to do ni i uklada pls
peta
Profil *
Doom4
www.volny.cz/peter.mlich/www.htm#lmoje
- viz guestbooky, prvni, pri pridavani volam funkci pro hledani IP v ban tabulce. Proste klasickym SELECT se pokusis najit podle nejakeho kriteria tu prezdivku a kdyz ji najde, script se vrati bez pridavani.

treba jiny priklad...
zpracujlogin.php
<?
ob_start();
session_start();
$where="login";

if(count($HTTP_POST_VARS))
{
$login = $_POST['userLogin'];
$psw = $_POST['userPsw'];
}


include("./pp_option.php");


$chyba='';


$ip=getIP();
$i=0;$i=PPfindIP($tb1,$ip);
if($i===0)
{
/* hledani loginu */
if ($login!="" && $psw!="")
{
$psw = md5($login.$psw); /* sifrovani hesla */

$i=0;$i=PPfinduser($tb1,$login,$psw);
if($i===1)
{

$_SESSION['login'] = $login;
$_SESSION['psw'] = $psw;

$tabulka = $tb1."user";
$dotaz = "UPDATE $tabulka SET `user_lastdate`=NOW(),`user_where`='$where' WHERE `id`='$id' LIMIT 1";
mysql_query($dotaz) or die("Error: DB user online: ".mysql_error());
$chyba.= "| Uzivatel <b>".$login. "</b> ";
}
else $chyba.= "| Heslo nebo Uzivatel je chybne! ";
}
else $chyba.= "| Neni zadany uzivatel nebo heslo nebo obsahuji nepovolene znaky, viz registrace! ";
}
else $chyba.= "| Banovane ip! ";

mysql_Close();

/*echo "<br />".$chyba;*/

Header( "Location: ".$fn1."status.php?". session_name() ."=". session_id() );

ob_end_flush();
?>

------------
option.php
<?

/* PhpMyAdmin: http://mysql.xhosting.cz */
$pocitac = "localhost"; //server (host)
$databaze = "mracek_xhosting_cz"; //MySQL DB name
$uzivatel = "mracek.xhosting.cz"; //MySQL user
$heslo = "heslo"; //MySQL password

$fn1="./pp_";
$tb1="pp_";
$lang = array(
'CZ' =>array("Cesky",".CZ"),
'EN' =>array("English",".EN")
);

$skins = array(
'0' =>"none",
'1' =>"minimal"
);

$races = 9;
$messages= array(10,20,50);

include("a-lang.php");

mysql_connect($pocitac,$uzivatel,$heslo) or die("Error: Nepripojen k DB serveru!");
mysql_select_db($databaze) or die ("Error: Nepripojen k BD!");


if(count($HTTP_POST_VARS))
{
if ($_POST['login']) {$login=$_POST['login'];/*$login=Ereg_Replace("[^a-zA-Z0-9]","",$login );*/}
if ($_POST['psw']) {$psw =$_POST['psw'] ;/*$psw =Ereg_Replace("[^a-f0-9]","",$psw);*/}
if ($_POST['lang']) {$l =$_POST['lang' ];$l =Ereg_Replace("[^0-9]",0,$l);}
if ($_POST['msgs']) {$msgs =$_POST['msgs' ];/*$msgs =Ereg_Replace("[^0-9]","",$msgs);*/}
if ($_POST['from']) {$from =$_POST['from' ];/*$from =Ereg_Replace("[^0-9]","",$from);*/}

}

function getIP(){
$ip="";
$ip1=getenv('REMOTE_ADDR');$ip2=getenv('HTTP_X_FORWARDED_FOR'); /* ip1-proxy, ip2-behind proxy */
if($ip2!='' && ip2long($ip2)!=-1) $ip=ip2long($ip2);else $ip=$ip1;
$ip=substr($ip,0,15);
return $ip;
}

/* banned IP? */
function PPfindIP($t,$a){
$v=0;
$tabulka = $t."banned";
$dotaz = "SELECT * FROM $tabulka WHERE `banip`='$a' LIMIT 0 , 1";
$vysledek= mysql_query($dotaz) or die("Error: DB banip! = ".mysql_error());
$v=mysql_NumRows($vysledek);
return $v;
}

/* user exist? */
function PPfindUser($t,$a,$b){
$v=0;
$tabulka = $t."user";
$dotaz = "SELECT * FROM $tabulka WHERE `user_login` = '$a' AND `user_psw` = '$b' LIMIT 1";
$vysledek= mysql_query($dotaz) or die("Error: DB user nalezen! (userfind): ".mysql_error());
$v=mysql_num_rows($vysledek);
return $v;
}

/* user exist2? */
function PPfindUser2($t,$a,$b){
$v=0;
$tabulka = $t."user";
$dotaz = "SELECT * FROM $tabulka WHERE `user_login` = '$a' AND `user_psw` = '$b' LIMIT 1";
$v = mysql_query($dotaz) or die("Error: DB user nalezen! (userfind): ".mysql_error());
return $v;
}


/* Kontrola loginu
$login = Ereg_Replace("[^a-zA-Z0-9]", "" , $login);

/* Kontrola hesla
$psw = Ereg_Replace("[^a-zA-Z0-9]", "" , $psw);
*/

include("./a-race2.php");

?>


-----------
logovaciformular.php

<? $where='login';include("./a-head.php"); ?>

<!-- <body onload="document.f.userLogin.focus()"> -->

<div class="body1">
<center><h3>PP: <?=$lng['m1_'.$where]?></h3></center>



<form name="f" action="<?=$fn1?>zuserlogin.php" method="post">
<fieldset>
<legend><?=$lng['m1_'.$where]?></legend>
<table align="center">
<tr valign="top">
<td><b>Login</b></td>
<td><input type="text" name="userLogin" /></td>
</tr>
<tr valign="top">
<td><b>Password</b></td>
<td><input type="password" name="userPsw" /></td>
</tr>
</table>
<center>
<input type="submit" value="<?=$lng['b_Submit']?>" class="butt" />
</center>
</fieldset>
</form>
</div>

</body>
</html>
Doom4
Profil *
UF nejde to jednodusseji pres JS treba ? :-(
Toto téma je uzamčeno. Odpověď nelze zaslat.