Jump to content
php.lv forumi

izmest erroru un nepildīt funkciju ..


snach15

Recommended Posts

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>";} ?>

Link to comment
Share on other sites

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ā.

Link to comment
Share on other sites


$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;

}

 

 

Link to comment
Share on other sites

  • 3 weeks later...

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 ?

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
×
×
  • Create New...