Ocena wątku:
  • 1 głosów - średnia: 5
  • 1
  • 2
  • 3
  • 4
  • 5
[PHP] sonda - bardzo skomplikowany problem - POMOCY ! ! !
#7
te kody mają być tylko w pliku i nie muszą się pokazywać użytkownikowi. Zresztą, porzuciłem już ten kod bo nie potrafiłem tego zrobić i zacząłem wszystko od początku.
Kod:
<?php    
//GENEROWANIE KODU 5-CYFROWEGO
for ($s=0; $s<50; $s++){
    srand((double)microtime()*1000000);
    $kod=md5(uniqid(rand()));
    // obliczamy ilość znaków w tekscie
    $licz = strlen($kod);
    // sprawdzamy, czy ilość znaków w tekscie jest większa
    // lub równa liczbie znaków po jakiej tekst ma być obcięty
    if ($licz>=5){
        // obcinamy tekst o określoną ilośc znaków
        $txt = substr($kod,0,5);
    }
    else{
        // jeżeli warunek nie jest spełniony pozostawiamy tekst bez zmian
        $txt = $kod;
    }    
    $kody[] = $txt; // tutaj zapisujemy okrojony kod do tablicy
}
file_put_contents('./kody.txt', implode(PHP_EOL, $kody));
//-------------------------------------------------------------------

//GŁOSOWANIE PO WPISANIU HASLA
if(isset($_POST['haslo']) && in_array($_POST['haslo'], $kody, true) && $_POST['glosuj']){
    //ZAPISYWANIE WYNIKOW DO PLIKOW
    if(isset($_POST['auto1']) && $_POST['auto1'] != ''){
    $filename1 = $_POST['auto1'] . '.txt';
    $auto1 = file_get_contents($filename1);
    $auto1++;
    $fileHandler=fopen("auto1.txt","w");
    fputs($fileHandler,$auto1);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto2']) && $_POST['auto2'] != ''){
    $filename2 = $_POST['auto2'] . '.txt';
    $auto2 = file_get_contents($filename2);
    $auto2++;
    $fileHandler=fopen("auto2.txt","w");
    fputs($fileHandler,$auto2);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto3']) && $_POST['auto3'] != ''){
    $filename3 = $_POST['auto3'] . '.txt';
    $auto3=file_get_contents("auto3.txt");
    $auto3++;
    $fileHandler=fopen("auto3.txt","w");
    fputs($fileHandler,$auto3);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto4']) && $_POST['auto4'] != ''){
    $filename4 = $_POST['auto4'] . '.txt';
    $auto4=file_get_contents("auto4.txt");
    $auto4++;
    $fileHandler=fopen("auto4.txt","w");
    fputs($fileHandler,$auto4);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto5']) && $_POST['auto5'] != ''){
    $filename5 = $_POST['auto5'] . '.txt';
    $auto5=file_get_contents("auto5.txt");
    $auto5++;
    $fileHandler=fopen("auto5.txt","w");
    fputs($fileHandler,$auto5);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto6']) && $_POST['auto6'] != ''){
    $filename6 = $_POST['auto6'] . '.txt';
    $auto6=file_get_contents("auto6.txt");
    $auto6++;
    $fileHandler=fopen("auto6.txt","w");
    fputs($fileHandler,$auto6);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto7']) && $_POST['auto7'] != ''){
    $filename7 = $_POST['auto7'] . '.txt';
    $auto7=file_get_contents("auto7.txt");
    $auto7++;
    $fileHandler=fopen("auto7.txt","w");
    fputs($fileHandler,$auto7);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto8']) && $_POST['auto8'] != ''){
    $filename8 = $_POST['auto8'] . '.txt';
    $auto8=file_get_contents("auto8.txt");
    $auto8++;
    $fileHandler=fopen("auto8.txt","w");
    fputs($fileHandler,$auto8);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto9']) && $_POST['auto9'] != ''){
    $filename9 = $_POST['auto9'] . '.txt';
    $auto9=file_get_contents("auto9.txt");
    $auto9++;
    $fileHandler=fopen("auto9.txt","w");
    fputs($fileHandler,$auto9);
    fclose($fileHandler);
    }

    elseif(isset($_POST['auto10']) && $_POST['auto10'] != ''){
    $filename10 = $_POST['auto10'] . '.txt';
    $auto10=file_get_contents("auto10.txt");
    $auto10++;
    $fileHandler=fopen("auto10.txt","w");
    fputs($fileHandler,$auto10);
    fclose($fileHandler);
    }

    $error = "dziękujemy za oddanie głosu";    
}
elseif($_POST['glosuj']){
    $error = "wpisałeś złe hasło lub nie wpisałeś wcale";
}
//------------------------------------------------------------------
        /*POKAZUJE SONDE*/
        echo '<p><map glosuj="glosuj">
        <form action="" method="post">
        <table align="center" style="text-align:center;">
        <tr>
            <td>1.<img src="./zdjecia/auto1.jpg" alt="" /></td>
            <td>2.<img src="./zdjecia/auto2.jpg" alt="" /></td>
            <td>3.<img src="./zdjecia/auto3.jpg" alt="" /></td>
            <td>4.<img src="./zdjecia/auto4.jpg" alt="" /></td>
            <td>5.<img src="./zdjecia/auto5.jpg" alt="" /></td>
        </tr>
        <tr>
            <td>6.<img src="./zdjecia/auto6.jpg" alt="" /></td>
            <td>7.<img src="./zdjecia/auto7.jpg" alt="" /></td>
            <td>8.<img src="./zdjecia/auto8.jpg" alt="" /></td>
            <td>9.<img src="./zdjecia/auto9.jpg" alt="" /></td>
            <td>10.<img src="./zdjecia/auto10.jpg" alt="" /></td>
        </tr>
        </table>
            
        <div>    
            <input type="radio" name="auto" value="auto1" checked="checked"/> nr 1.  
            <input type="radio" name="auto" value="auto2" /> nr 2.  
            <input type="radio" name="auto" value="auto3" /> nr 3.  
            <input type="radio" name="auto" value="auto4" /> nr 4.  
            <input type="radio" name="auto" value="auto5" /> nr 5.  
            <input type="radio" name="auto" value="auto6" /> nr 6.  
            <input type="radio" name="auto" value="auto7" /> nr 7.  
            <input type="radio" name="auto" value="auto8" /> nr 8.  
            <input type="radio" name="auto" value="auto9" /> nr 9.  
            <input type="radio" name="auto" value="auto10" /> nr 10.
        </div>
        
        <p></p><div><br/> <input type="text" name="haslo"/><input type="submit" name="glosuj" value="głosuj" /><br/>';echo $error;'<br/></form></map></p>';
?>
obecnie mam coś takiego i mam problem z tym, że nie mogę wpisać nigdy poprawnego hasła w sondzie ponieważ uaktualnia się ona za każdym razem i jak klikam głosuj to kody już są zmienione na inne... tak mi się wydaje - chyba że problem leży w czymś innym, nie mam pojęcia.
Odpowiedz


Wiadomości w tym wątku
RE: [PHP] sonda - bardzo skomplikowany problem - POMOCY ! ! ! - przez eremen - 21-02-2012, 23:54

Podobne wątki…
Wątek: Autor Odpowiedzi: Wyświetleń: Ostatni post
  Pomocy [php/mysql] online Marekgo 6 4,849 21-10-2012, 22:03
Ostatni post: Morfeusz_2005
  Potrzebuję Waszej pomocy Mr. Bum 4 3,460 11-03-2012, 03:25
Ostatni post: Mr. Bum
  BARDZO PILNE - WORDPRESS eremen 3 2,967 07-03-2012, 17:29
Ostatni post: Engine
  System logowania - pomocy jani1992 4 3,185 24-09-2011, 16:02
Ostatni post: KowR
  Pomocy pawel274 9 6,742 22-08-2011, 19:45
Ostatni post: KowR

Skocz do:


Użytkownicy przeglądający ten wątek:
Sponsorzy i przyjaciele
SeoHost.pl