snach15 Posted September 20, 2010 Report Share Posted September 20, 2010 Izmēģināju ar die; bet tas arī nepalīdz .. nesaprotu kā lai aptur tajā brīdī ielagošanos ja piemēram lietotājs ievadījis accountname un kādu no invalid charteriem piemēram "#" .. man šādā gadījumā ja piemēram viņam accounts = "testeris" un viņs ievada = "testeris#" .. vienalga notiek ielagošanās tikai bonusā izmet erroru "Username contains invalid characters" .. liekot aiz errora die; man tas situāciju neatrisināja jo tad itkā izmet erroru un neielagojas bet pēc refresh vienalga accounts ir ielagojies .. kā izlabot kļūdu ? <? if ((isset($_SESSION['pass'])) && (isset($_SESSION['user']))) { if ((isset($_POST['pass'])) && (isset($_POST['login']))) { $login = $_POST['login']; $pass = $_POST['pass']; $allowed = "#[^a-zA-Z0-9_\-]#"; if(empty($login) || empty($pass)) { echo '<font color = red size=2><b>Incorrect Login or Password.<br>';} if (preg_match($allowed,$login)) { echo '<font color = red size=2><b>Username contains invalid characters<br>';} if (preg_match($allowed,$pass)) { echo '<font color = red size=2><b>Password contains invalid characters<br>';} $check_user = mssql_query("select * from MEMB_INFO where memb___id='$login'"); $check_ok = mssql_num_rows($check_user); if($check_ok=="1") {} else { echo '<font color = red size=2><b>Incorrect Login or Password.<br>';}} $check = mssql_query("Select AdminAccess from MEMB_INFO where memb___id ='$_SESSION[user]'"); $check = mssql_fetch_row($check); $check = $check[0]; if($check == "1") { echo "<div align='left' title='Control Panel' class='link_menu'><a href='index.php?page=admin'><b>Admin panel</b></a></div>";} echo "<form action='index.php' method='post' name='logout_account' id='logout_account'> <table width='164' border='0' cellspacing='0' cellpadding='0'> <tr> <input name='logoutaccount' type='hidden' id='logoutaccount' value='logoutaccount'></td> </tr> <tr> <td width='104' scope='row'><div align='left' title='Control Panel' class='link_menu'><a href='index.php?page=acc'>Account Panel</a></div></td><tr> <td width='104' scope='row'><div align='left' title='Control Panel' class='link_menu'><a href='index.php?page=char'>Character(s) Panel</a></div></td><tr> <th width='104' height='33' scope='row'><div align='left'> <input name='Logout!' type='submit' class='button' id='Logout!' title='Logout!' value='Logout!'> <span class='style1'> [$_SESSION[user]]</span></div> </th><tr> </tr> </table> </form>";} else { echo "<form action='index.php' method='post' name='login_account' id='login_account'> <table width='164' border='0' cellspacing='0' cellpadding='0'> <tr> <td height='16' colspan='2' align='left' class='style1' scope='row'>Username</td> </tr> <tr> <th height='16' colspan='2' scope='row'><div align='left'> <input name='login' type='text' class='login_field' id='login' title='Username' size='15' maxlength='10'> <input name='account_login' type='hidden' id='account_login' value='account_login'> </div></th> </tr> <tr> <td height='16' colspan='2' class='style1' scope='row' align='left'>Password</td> </tr> <tr> <th colspan='2' scope='row'><div align='left'> <input name='pass' type='password' class='login_field' id='pass' title='Password' size='15' maxlength='10'> </div></th> </tr> <tr> <th width='62' height='33' scope='row'><div align='left'> <input name='Submit' type='submit' class='button' value='Login!' title='Login'> </div></th> <td width='104' scope='row'><div align='left' title='Lost Password' class='link_menu'><a href='index.php?page=lostpassword'>Lost Password </a></div></td> </tr> </table> </form> <p>";} ?> Quote Link to comment Share on other sites More sharing options...
briedis Posted September 20, 2010 Report Share Posted September 20, 2010 Nu, tu nevari izveidot vienu mainīgo, kas piemēram skaita kļūdas? $kļūdas = 0; if(pārbaude == false){ $kļūdas++; } //.... citas pārbaudes if($kļūdas == 0){ //Nav kļūdu, ielogojam }else{ //Ir kļūdas, sūtam ellē rattā exit("Ej prom!"); } Quote Link to comment Share on other sites More sharing options...
snach15 Posted September 21, 2010 Author Report Share Posted September 21, 2010 Pāldies mēģināšu Quote Link to comment Share on other sites More sharing options...
Vhubuo Posted September 21, 2010 Report Share Posted September 21, 2010 Nu, tu nevari izveidot vienu mainīgo, kas piemēram skaita kļūdas? $kļūdas = 0; if(pārbaude == false){ $kļūdas++; } //.... citas pārbaudes if($kļūdas == 0){ //Nav kļūdu, ielogojam }else{ //Ir kļūdas, sūtam ellē rattā exit("Ej prom!"); } Manuprat labak saglabat kļudas ar to aprakstiem masiva. Un pec tam ja masivs nav tukš izvadit kļudas ciklā. Quote Link to comment Share on other sites More sharing options...
edi Posted September 21, 2010 Report Share Posted September 21, 2010 $error = false; if(empty($login) || empty($pass)) { $error = '<font color = red size=2><b>Incorrect Login or Password.<br>';} if (preg_match($allowed,$login)) { $error .= '<font color = red size=2><b>Username contains invalid characters<br>';} if (preg_match($allowed,$pass)) { $error .= '<font color = red size=2><b>Password contains invalid characters<br>';} if(!$error) { ejam talak } else { echo 'ERROR<br/>'.$error; } Quote Link to comment Share on other sites More sharing options...
snach15 Posted October 7, 2010 Author Report Share Posted October 7, 2010 edi paldies šis derēja .. bet tagad jautājums tāds .. ja man piemeŗam ir šādi $error = "error1"; $error = "error2"; $error = "error3"; kā lai viņš parāda visus 3 errorus reizē nevis tikai vienu ? Quote Link to comment Share on other sites More sharing options...
Code Posted October 7, 2010 Report Share Posted October 7, 2010 Taisi tā kā edi parādīja - ar katru notikušo kļūdu, liec tam mainīgajam nākamās kļūdas tekstu klāt nevis katru reizi pārraksti tā vērtību. Quote Link to comment Share on other sites More sharing options...
briedis Posted October 7, 2010 Report Share Posted October 7, 2010 nu jēziņ, saliec tak kaut vai masīvā un izdrukā ar foreach! Quote Link to comment Share on other sites More sharing options...
snach15 Posted October 8, 2010 Author Report Share Posted October 8, 2010 Code - liels tev paldies.. briedis - ja negribi palīdzēt tad nelīdzi! nējav visi ir kautkādi "pro" uzsitiena .. Quote Link to comment Share on other sites More sharing options...
briedis Posted October 8, 2010 Report Share Posted October 8, 2010 Nu tad kļūsti par PRO un iemācies, kas ir masīvs. 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.