Ban ip in tabel mysql

Discutii despre script-uri si coduri PHP-MySQL, precum si lucru cu XML in PHP.
calynutz_baciu
Mesaje:3

Ban ip in tabel mysql

Salut.
Am realizat la un website un 'script' pentru dedicatii cu baza de date mysql. in tabela dedicatii am urmatoarele campuri (id, dela, oras, pentru, mesaj, ip, data, h). Cand cineva trimite o dedicatie ii memoreaza si ip-ul pentru securitate. In formularul prin care extrag datele din baza de date am facut un tabel si folosesc comanda "while ($rrows = mysql_fetch_array($rs_results))" si in tabel imi extrage in fiecare linie cate o dedicatie. Problema e urmatoarea, mai am o tabela "ban" in care am campurile (id, ban, dj, ipdj, date, h). id este autoincrement, ban=ip-ul banat, etc.

Acesta e tabelul in care extrag datele:

Cod: Selectaţi tot

<form action="dedicatii.php" method="post">
  <table width="800" border="1" align="center" bordercolor="#CCCCFF">
    <tr>
      <th width="36" align="center" scope="col" bgcolor="#CCCCCC">ID</th>
      <th width="58" align="center" scope="col" bgcolor="#CCCCCC">Numar</th>
      <th colspan="2" align="center" scope="col"bgcolor="#CCCCCC"> Dedicatii - DJ</th>
      <th colspan="2" align="center" valign="middle" bgcolor="#CCCCCC" scope="col">IP</th>
      <th width="89" align="center" valign="middle" bgcolor="#CCCCCC" scope="col">Admin/DJ</th>
    </tr>
    <?php while ($rrows = mysql_fetch_array($rs_results)) {?>
    <tr>
      <td rowspan="4" align="center" bgcolor="#CCCCFF" bordercolor="#FFE0CC"><input type="checkbox" name="checkbox[]" id="checkbox[]" value="<? echo $rrows['ID']; ?>"/></td>
      <td rowspan="4" align="center" bgcolor="#CCCCFF" bordercolor="#FFE0CC"><? echo $rrows['ID']; ?></td>
      <td width="107" nowrap="nowrap" bgcolor="#FFE0CC" bordercolor="#FFE0CC">De la:</td>
      <td width="304" nowrap="nowrap" bgcolor="#FFE0CC" bordercolor="#FFE0CC"><? echo $rrows['dela']; ?></td>
      <td colspan="2" rowspan="2" align="center" valign="middle" bgcolor="#CCCCFF"><? echo $rrows['ip']; ?></td>
      <td rowspan="3" align="center" valign="middle" bgcolor="#CCCCFF"><input name="Delete" type="submit" id="Delete" value="Delete" /></td>
    </tr>
    <tr>
      <td bgcolor="#FFE0CC" bordercolor="#FFE0CC">Din orasul:</td>
      <td bgcolor="#FFE0CC" bordercolor="#FFE0CC"><? echo $rrows['oras']; ?></td>
    </tr>
    <tr>
      <td bgcolor="#FFE0CC">Pentru:</td>
      <td bgcolor="#FFE0CC" bordercolor="#FFE0CC"><? echo $rrows['pentru']; ?></td>
      <td width="59" align="center" valign="middle" bgcolor="#CCCCFF">Data:</td>
      <td width="101" align="center" valign="middle" bgcolor="#CCCCFF"><? echo $rrows['date']; ?></td>
    </tr>
    <tr>
      <td bgcolor="#FFE0CC" bordercolor="#FFE0CC">Mesaj:</td>
      <td bgcolor="#FFE0CC" bordercolor="#FFE0CC"><? echo $rrows['mesaj']; ?></td>
      <td align="center" valign="middle" bgcolor="#CCCCFF">Ora:</td>
      <td align="center" valign="middle" bgcolor="#CCCCFF"><? echo $rrows['h']; ?></td>
      <td align="center" valign="middle" bgcolor="#CCCCFF"><input name="doBan" type="submit" id="doBan" value="Ban" /></td>
    </tr>
    <tr>
      <td height="1" colspan="7" align="center" bgcolor="#CCCCCC"></td>
    </tr>
    <?php } ?>
    
  </table>
</form>
si asa am incercat sa introduc in tabela "ban" ip-ul banat si inca niste date de siguranta:

Cod: Selectaţi tot

 if($_POST['doBan']) {
    for($i=0; $i<count($_POST['checkbox']); $i++) {
        $ban_id = $_POST['checkbox'][$i];
        $sql = "INSERT INTO ban VALUES (' ','$ban','$dj','$ipdj','$date','$h')";
        mysql_query($sql);
         header('Refresh: 1');
    }
}
nu imi dau seama cum sa definesc $ban din linia

Cod: Selectaţi tot

$sql = "INSERT INTO ban VALUES (' ','$ban','$dj','$ipdj','$date','$h')";
ca sa imi introduca ip-ul dintr-o anumita linie din tabel.

Daca se poate putin ajutor, va rog? :D

calynutz_baciu Mesaje:3
am reusit. am pus inca un checkbox si s-a rezolvat problema.

Cod: Selectaţi tot

 if($_POST['doBan'] == "Ban") {
    for($i=0; $i<count($_POST['checkbox']); $i++) {
        $ban = $_POST['checkbox'][$i];
        $sql = "INSERT INTO ban VALUES (' ','$ban','$dj','$ipdj','$date','$h')";
        mysql_query($sql);
         
    }
}