Chapman Posted January 14, 2010 Report Share Posted January 14, 2010 (edited) es zinu, ka tas, laikam, nav pareizi, bet man ir if operators iekš cita if. kods: if (isset($_POST['login_start'])){ // Connect to server and select databse. mssql_connect("$host", "$username", "$password")or die("cannot connect"); mssql_select_db("SecKeyPrior")or die("cannot select DB"); // username and password sent from form $nick=$_POST['Nick']; $pw=$_POST['passw']; // To protect MySQL injection (more detail about MySQL injection) $nick = stripslashes($nick); $pw= stripslashes($pw); $sql="SELECT Id, Nick, pw, Locked, Error, F_Name, S_Name FROM S_Users WHERE Nick='$nick' and pw='$pw'"; $result=mssql_query($sql); $result2 = mssql_fetch_row($result); $blocked = $result2[3]; $errors = $result2[4]; if ( $blocked == '1' ) { $lockerror = "<div align=center> Tavs lietotājs ir bloķēts!</div>"; } else{ // Mysql_num_row is counting table row $count=mssql_num_rows($result); // If result matched $myusername and $mypassword, table row must be 1 row //autorizācijas parbaude if($count==1){ $dati = "SELECT Id, F_Name, S_name, Nick, Is_Admin FROM S_Users WHERE Nick='$nick' and pw='$pw'"; $dati = mssql_query( $dati ); $dati = mssql_fetch_row($dati); $id = $dati[0]; $Vards = $dati[1]; $Uzvards = $dati[2]; $niks = $dati[3]; $admin = $dati[4]; setcookie("id", $id, time() + 3600); setcookie("Vards", $Vards, time() + 3600); setcookie("Uzvards", $Uzvards, time() + 3600); setcookie("Niks", $niks, time() + 3600); setcookie("Admin", $admin, time() + 3600); header("location: ?dome=main"); } else { $logerror = "<div align=center> Lietotājvārds un/vai parole nav pareizi ievadīta</div>"; mssql_query ( "Use SecKeyPrior UPDATE S_Users SET Error = Error+'1' WHERE Nick = '$nick' " ); if ( $errors > '3' ) { mssql_query ( "Use SecKeyPrior UPDATE S_Users SET Locked = 'True' WHERE Nick = '$nick'" ); } } } } es nesaprotu kāpēc man neizpildās tieši šī koda daļa: mssql_query ( "Use SecKeyPrior UPDATE S_Users SET Locked = 'True' WHERE Nick = '$nick'" ); Edited January 14, 2010 by Chapman Quote Link to comment Share on other sites More sharing options...
anonīms Posted January 14, 2010 Report Share Posted January 14, 2010 s ko izmet vnk echo $errors ? Quote Link to comment Share on other sites More sharing options...
Kavacky Posted January 14, 2010 Report Share Posted January 14, 2010 Visticamāk tāpēc, ka nosacījums "if ( $errors > '3' )" neizpildās, tas ir - $errors vērtība nepārsniedz teksta stringa '3' vērtību. Quote Link to comment Share on other sites More sharing options...
Chapman Posted January 14, 2010 Author Report Share Posted January 14, 2010 (edited) izpildās gan tas if, tikai ja vins atrodas ieksh else, tad tik neizpildaas :( bet man vinju vaig tieshi tur :( Edited January 14, 2010 by Chapman Quote Link to comment Share on other sites More sharing options...
2easy Posted January 14, 2010 Report Share Posted January 14, 2010 1) katrā if/while/... kodu liec ar atkāpi (parasti tab - 4x atstarpes). tā vieglāk lasīt blokus, uztvert loģiku, kur kas sākas un beidzas 2) else attiecas uz tuvāko if. ja tev nupat beidzas viens iekšējais if un tu gribi, lai else attiecas nevis to, bet uz ārējo if, tad ieliec vēl vienu } if () { if () { ... } else { ... } } if () { if () { ... } } else { ... } pamanīji atšķirību? es neteikšu priekšā, bet sakārtojot kodu, tev pašam atnāks apskaidrība ;) Quote Link to comment Share on other sites More sharing options...
Chapman Posted January 14, 2010 Author Report Share Posted January 14, 2010 man vaig, lai tas pedejais if izpildas, ja ir else!! bet ievietojot if ieksh else, vins neizpildaas :( Quote Link to comment Share on other sites More sharing options...
2easy Posted January 14, 2010 Report Share Posted January 14, 2010 paprasi savam prakses vadītājam, lai tev iemāca rakstīt if else Quote Link to comment Share on other sites More sharing options...
Chapman Posted January 14, 2010 Author Report Share Posted January 14, 2010 (edited) viss ok, partaisiju visu bik savadak :) Edited January 14, 2010 by Chapman Quote Link to comment Share on other sites More sharing options...
Kemito Posted January 14, 2010 Report Share Posted January 14, 2010 (edited) if() { ... } else{ if() { ... } else{ ... } } Nu neesmu testējis jau to UBER variāciju, bet domādams ka IESPĒJAMS ir! ;) Edited January 14, 2010 by Kemito Quote Link to comment Share on other sites More sharing options...
anonīms Posted January 14, 2010 Report Share Posted January 14, 2010 Ja prasi vai tas ir iespējams, tad ir! Iemet pirms tā if echo $errors; Quote Link to comment Share on other sites More sharing options...
Chapman Posted January 14, 2010 Author Report Share Posted January 14, 2010 pārtaisīju savādāk, lai nebutu ieksh else if :) Quote Link to comment 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.