Ciao a tutti,
ho cercato di scrivere un po' di codice php per fare i risultati di un gioco: il Sudoku.
Non ci sono riuscito.
Questo è il codice html della pagina con il form del sudoku:
Ora arriva il problema, questo è il codice php della pagina fsudokup.php:Codice HTML:<form method="post" action="fsudokup.php"> <table width="300" height="300" border="1" bordercolor="#000000"> <tr> <td><table class="8ptg" width="100" height="100"> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r1" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r2" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">4</td> </tr> <tr> <td width="33%" height="33%" align="center">5</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="6" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">6</td> </tr> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r10" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r11" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">7</td> </tr> </table></td> <td><table class="8ptg" width="100" height="100"> <tr> <td width="33%" height="33%" align="center">6</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r3" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">1</td> </tr> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r7" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">9</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r8" maxlength="1" size="1"></td> </tr> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r12" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r13" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r14" maxlength="1" size="1"></td> </tr> </table></td> <td><table class="8ptg" width="100" height="100"> <tr> <td width="33%" height="33%" align="center">8</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r4" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r5" maxlength="1" size="1"></td> </tr> <tr> <td width="33%" height="33%" align="center">4</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r9" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">2</td> </tr> <tr> <td width="33%" height="33%" align="center">6</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r15" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r16" maxlength="1" size="1"></td> </tr> </table></td> </tr> <tr> <td><table class="8ptg" width="100" height="100"> <tr> <td width="33%" height="33%" align="center">9</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r17" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r18" maxlength="1" size="1"></td> </tr> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r23" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">1</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r24" maxlength="1" size="1"></td> </tr> <tr> <td width="33%" height="33%" align="center">4</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r28" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r29" maxlength="1" size="1"></td> </tr> </table></td> <td> <table class="8ptg" width="100" height="100"> <tr> <td align="center" width="33%" height="33%"><input class="ns" type="text" name="r19" maxlength="1" size="1"></td> <td align="center" width="33%" height="33%">3</td> <td align="center" width="33%" height="33%"><input class="ns" type="text" name="r20" maxlength="1" size="1"></td> </tr> <tr> <td align="center" width="33%" height="33%">8</td> <td align="center" width="33%" height="33%"><input class="ns" type="text" name="r25" maxlength="1" size="1"></td> <td align="center" width="33%" height="33%">2</td> </tr> <tr> <td align="center" width="33%" height="33%"><input class="ns" type="text" name="r30" maxlength="1" size="1"></td> <td align="center" width="33%" height="33%">7</td> <td align="center" width="33%" height="33%"><input class="ns" type="text" name="r31" maxlength="1" size="1"></td> </tr> </table></td> <td><table class="8ptg" width="100" height="100"> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r21" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r22" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">7</td> </tr> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r26" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">6</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r27" maxlength="1" size="1"></td> </tr> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r32" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r33" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">8</td> </tr> </table></td> </tr> <tr> <td><table class="8ptg" width="100" height="100"> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r34" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r35" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">2</td> </tr> <tr> <td width="33%" height="33%" align="center">6</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r41" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">9</td> </tr> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r45" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r46" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">1</td> </tr> </table></td> <td><table class="8ptg" width="100" height="100"> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r36" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r37" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r38" maxlength="1" size="1"></td> </tr> <tr> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r42" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">1</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r43" maxlength="1" size="1"></td> </tr> <tr> <td width="33%" height="33%" align="center">9</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r47" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">7</td> </tr> </table></td> <td> <table class="8ptg" width="100" height="100"> <tr> <td width="33%" height="33%" align="center">9</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r39" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r40" maxlength="1" size="1"></td> </tr> <tr> <td width="33%" height="33%" align="center">7</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r44" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center">4</td> </tr> <tr> <td width="33%" height="33%" align="center">3</td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r48" maxlength="1" size="1"></td> <td width="33%" height="33%" align="center"><input class="ns" type="text" name="r49" maxlength="1" size="1"></td> </tr> </table></td> </tr> </table> </form>
Mi sapete aiutare a risolvere?Codice PHP:
<?php
$si = 0;
$no = 0;
$vu = 0;
$numeridati = array($_POST['r1'], $_POST['r2'], $_POST['r3'], $_POST['r4'], $_POST['r5'], $_POST['r6'], $_POST['r7'], $_POST['r8'], $_POST['r9'], $_POST['r10'], $_POST['r11'], $_POST['r12'], $_POST['r13'], $_POST['r14'], $_POST['r15'], $_POST['r16'], $_POST['r17'], $_POST['r18'], $_POST['r19'], $_POST['r20'], $_POST['r21'], $_POST['r22'], $_POST['r23'], $_POST['r24'], $_POST['r25'], $_POST['r26'], $_POST['r27'], $_POST['r28'], $_POST['r29'], $_POST['r30'], $_POST['r31'], $_POST['r32'], $_POST['r33'], $_POST['r34'], $_POST['r35'], $_POST['r36'], $_POST['r37'], $_POST['r38'], $_POST['r39'], $_POST['r40'], $_POST['r41'], $_POST['r42'], $_POST['r43'], $_POST['r44'], $_POST['r45'], $_POST['r46'], $_POST['r47'], $_POST['r48'], $_POST['r49']);
$numerigiusti = array(2, 9, 5, 7, 3, 8, 7, 3, 1, 1, 3, 2, 8, 4, 9, 5, 2, 8, 5, 6, 1, 4, 7, 3, 4, 5, 9, 6, 5, 1, 9, 2, 3, 3, 7, 4, 8, 5, 8, 1, 5, 3, 8, 2, 8, 4, 2, 5, 6);
if($numeridati == $numerigiusti) { $si++; }
else if ($numeridati == "") { $vu++; }
else { $no++; }
echo "Numeri azzeccati: ".$si."<br />Numeri sbagliati: ".$no."<br />Numeri mancanti: ".$vu;
?>
Grazie,
Ciao...