where's the mistake ???

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • where's the mistake ???

    the's a mistake somewhere in my code, i'm sure of that, because it doesn't work like it should, but after spending a couple of weeks on it, i'm just too frustrated now

    here's the code:
    PHP-Code:
    <?php
    $dbhost
    ="***";
    $dbuser="***";
    $dbname="***";
    $db mysql_connect("$dbhost""$dbuser");
    mysql_select_db("$dbname");

    $login=$_POST['login'];
    $passwd=$_POST['passwd'];
     
    if (!
    $login) {
    echo 
    "Neteisingai Ávestas Vartotojo Vardas";
    } elseif (!
    $passwd) {
    echo 
    "Neteisingai Ávestas Slaptaþodis";
    } else {
    check_logina($login$passwd)) {
    print_mb(); 
    ) else {
    echo 
    "klaida";
    }
    mysql_close($db);
    ?>

    <?php
    function check_logina($login$passwd) {
    global 
    $dbhost$dbname$dbuser$login
    $failas "/var/ipac/etc/passwd"
    $duomenys fopen ($failas"r"); 
    $index=0
    while (!
    feof($duomenys)) { 
    $eilute[$index] = fgetss($duomenys100); 
    list(
    $useris$slaptazodis$workdyra$kazkas) = explode("*"$eilute[$index]); 
    if (
    $login==$useris && $passwd==$slaptazodis) { 
    return 
    1
    } else { 
    return 
    0; } 

    fclose ($duomenys); 
    $index++; 
    }
    ?>

    <?php
    function print_mb() {
    global 
    $dbhost$dbname$dbuser$login$kazkas;
    $rezult mysql_query("SELECT round(sum(issiusta)/1024/1024) from statistika where vardas='".$login."' and HOUR(laikas) > 9 and HOUR(laikas) < 21");
    while (
    $row mysql_fetch_row($rezult))
    echo 
    $row[0].'<br />';
    mysql_free_result($rezult);
    }
    ?>
    i think it's wither this part
    PHP-Code:
    if (!$login) {
    echo 
    "Neteisingai Ávestas Vartotojo Vardas";
    } elseif (!
    $passwd) {
    echo 
    "Neteisingai Ávestas Slaptaþodis";
    } else {
    check_logina($login$passwd)) {
    print_mb(); 
    ) else {
    echo 
    "klaida";

    or the function check_logina, coz the print_mb works perfectly alone...
    i'm getting the $login and $pass from another php file's form.
    please help.

  • #2
    Hey,

    I see, you like it here!

    EDIT:
    Was "Schmarn" what I posted here!


    PS: Perhaps I'll find time to answer your questions tomorrow, but at the moment i've my own ones.
    Zuletzt geändert von TobiaZ; 19.03.2003, 20:47.

    Kommentar


    • #3
      yeah, you guys here are cool! you've helped me with all my questions so far!

      Kommentar


      • #4
        have you tried echo $login.$passwd; ???

        Kommentar


        • #5
          you mean just to check if they are ok ??? well yes, i have... :/ and everything's fine. i can see the user name and the password...

          Kommentar


          • #6
            then please tell me, what happens, when you execute your script. are there errors or what does the script "say" to you?

            Kommentar


            • #7
              PHP-Code:
              function check_logina($login$passwd)
              {
                  echo 
              'validating login information';
                  global 
              $dbhost$dbname$dbuser$login
                  
              $failas "/var/ipac/etc/passwd"
                  
              $duomenys fopen ($failas"r"); 
                  if (!
              $doumenys)
                      echo 
              '<p />error opening file';
                  
              $index=0
                  
              $ok=false;
                  while (!
              feof($duomenys)) 
                  { 
                      
              $eilute[$index] = fgetss($duomenys100); 
                      list(
              $useris$slaptazodis$workdyra$kazkas) = explode("*"$eilute[$index]); 
                      if (
              $login==$useris and $passwd==$slaptazodis)
                      {
                          
              $ok=true;
                          echo 
              '<p />found entry - login successful';
                          break;
                      }
                      
              $index++; 
                  } 
                  
              fclose ($duomenys); 
                  return 
              $ok;

              should work (at least i hope so )
              if i've analyzed your function correctly you always return 0 (zero) wich equals false
              Ich denke, also bin ich. - Einige sind trotzdem...

              Kommentar


              • #8
                "validating login information
                error opening file"

                i know the file is there, but why can't i open it???

                Kommentar


                • #9
                  "error opening file

                  found entry - login successful 7895(Mb used)"

                  This is the info i get from the code you wrote above... :-) so how do i correct it ???

                  Kommentar

                  Lädt...
                  X