Nico: Daten eintragen bzw. hinzufügen

Beitrag lesen

Ich poste euch mal den kompletten code zum veranschaulichen meines vorhabens

<html>

<head>
	<title>Blacklist-Wörterbuch</title>
	<link rel="stylesheet" type="text/css" href="style.css">
	<script type="text/javascript">
function eingaben_ueberpruefen(){
 if (document.Form.eingabe.value.length != 5){
  alert("Bitte geben Sie den Code ein!");
  document.Form.eingabe.focus();
  return false;
 }
 else
 return true;
}


function RND(){
 Zufall = Math.round(Math.random()*11+1);
 document.Form.code.value=Zufall;
 return Zufall;
}
</script>
</head>
<font size="+2" color="#000000">Geben Sie hier bitte Ihr Blacklist-Wort ein</font>
<body onLoad="document.Form.eingabe.focus();">
<?php
// Spam-Schutz
$eingabe = @$_POST["eingabe"];
$eingabe = strtolower($eingabe);
$code = @$_POST["code"];

if(@$_POST["eingabe"] !=""){

 $chluessel[1] = "dsnxn";
 $chluessel[2] = "tepsh";
 $chluessel[3] = "5fwnb";
 $chluessel[4] = "fs7ha";
 $chluessel[5] = "5ress";
 $chluessel[6] = "ywyyw";
 $chluessel[7] = "lcvr7";
 $chluessel[8] = "gskaw";
 $chluessel[9] = "u7twn";
 $chluessel[10] = "4x8uw";
 $chluessel[11] = "wtwem";
 $chluessel[12] = "ehewh";
 $chluessel[13] = "ehxdh";
 $chluessel[14] = "asewh";
 $chluessel[15] = "756wh";
 $chluessel[16] = "58fkg";
 $chluessel[17] = "t23re";
 $chluessel[18] = "flgöt";
 $chluessel[19] = "nizza";
 $chluessel[20] = "235ht";
 $chluessel[21] = "99984";
 $chluessel[22] = "zuiol";
 $chluessel[23] = "denke";
// Weitere Schlüssel ab hier eingeben!

// Überprüfung
 if ($chluessel[$code] == $eingabe) {
  echo "<br><font color=blue>Die Eingabe war richtig.</font>";
 }
 else {
  echo "<br><font color=red>Die Eingabe war falsch!</font>";
 }
}
?>
<form name="Form" action="<?php echo $_SERVER["PHP_SELF"]; ?>" method="post" onSubmit="return eingaben_ueberpruefen(this.form)">
<table>
 <tr>
  <td>Wiederholen Sie<br>folgenden Code<br><small>(Dies verhindert SPAM)</small></td>
  <td>
   <input type=hidden name="code">
   <script type="text/javascript">document.write('<img src="'+RND()+'A.gif" width=210 height=50>');</script>
  </td>
 </tr>
 <tr>
  <td></td>
  <td><input type=text name="eingabe" style="text-transform: uppercase;"></td>
 <tr>
  <th colspan=2>
    <br>
	<td>Blacklist Wort</td>
  <td><input type="text" name="bw"></td>
   <input type=submit> &nbsp; <input type=reset>
  </th>
 </tr>
</table>
</form>
<?
include ('../config/db2.inc.php');
$ip= $_SERVER['REMOTE_ADDR'];
$bw=$_POST['bw'];
$sql = "SELECT count(*) AS anzahl FROM blacklist WHERE blackword = '".$_POST['bw']."'";
$ipchek="SELECT ip FROM blacklist WHERE ip= '".$ip."'";
$ipquery=mysql_query($ipchek) or die (mysql_error());
$iprow=mysql_fetch_object($ipquery);
$query = mysql_query($sql) or die(mysql_error());
$row = mysql_fetch_object($query);
if($row->anzahl > 0)
  echo 'Wort vorhanden';
  else
  {
  	  if (isset($bw)){
  	  	$hinzu = "INSERT INTO blacklist (blackword, ip)

	VALUES ('$bw')";
	mysql_query($hinzu) or die(mysql_error());
	echo "$bw wurde erfolgreich in unsere Datenbank eingetragen.";

	}
}
?>
<form action="<? $_SERVER['PHP_SELF'] ?>" method="GET">
<table>
<tr>
	<td><select size="1" name="list">
	<option value="1">1</option>
	<option value="5">5</option>
	<option value="10">10</option>
	<option value="15">15</option>
	<option selected="selected" value="20">20</option>
	<option value="25">25</option>
	<option value="30">30</option>
	<option value="35">35</option>
	<option value="40">40</option>
	<option value="45">45</option>
	<option value="50">50</option>
	<option value="60">60</option>
	<option value="70">70</option>
	<option value="80">80</option>
	<option value="90">90</option>
	<option value="100">100</option>
</select></td>
	<td><input type="submit" value="Auswählen"></td>
	<td><input type="submit" value="Alle" name="clear"></td>
	<td><input type="submit" value="A" name="sort"></td>
	<td><input type="submit" value="B" name="sort"></td>
	<td><input type="submit" value="C" name="sort"></td>
	<td><input type="submit" value="D" name="sort"></td>
	<td><input type="submit" value="E" name="sort"></td>
	<td><input type="submit" value="F" name="sort"></td>
	<td><input type="submit" value="G" name="sort"></td>
	<td><input type="submit" value="H" name="sort"></td>
	<td><input type="submit" value="I" name="sort"></td>
	<td><input type="submit" value="J" name="sort"></td>
	<td><input type="submit" value="K" name="sort"></td>
	<td><input type="submit" value="L" name="sort"></td>
	<td><input type="submit" value="M" name="sort"></td>
	<td><input type="submit" value="N" name="sort"></td>
	<td><input type="submit" value="O" name="sort"></td>
	<td><input type="submit" value="P" name="sort"></td>
	<td><input type="submit" value="Q" name="sort"></td>
	<td><input type="submit" value="R" name="sort"></td>
	<td><input type="submit" value="S" name="sort"></td>
	<td><input type="submit" value="T" name="sort"></td>
	<td><input type="submit" value="U" name="sort"></td>
	<td><input type="submit" value="V" name="sort"></td>
	<td><input type="submit" value="W" name="sort"></td>
	<td><input type="submit" value="X" name="sort"></td>
	<td><input type="submit" value="Y" name="sort"></td>
	<td><input type="submit" value="Z" name="sort"></td>
</tr>
</table>
</body>
</html>
<?
include ('../config/db2.inc.php');

if (isset($_GET['sort']))
{
$buchstabe = $_GET['sort'];
}
	else
	{
	$buchstabe = "A";
	}
$query = "SELECT blackword FROM blacklist WHERE blackword LIKE '". $_GET['sort'] ."%' ORDER BY blackword ASC LIMIT 2";

$res = mysql_query($query) or die(mysql_error());
$optlist=$_GET['list'];
if (!isset($_GET['list'])){
$Zeilen_pro_Seite = 20;
}
else {
	$Zeilen_pro_Seite = $_GET['list'];
}
if (!isset($_GET['site'])) {
  $Anfangsposition = 0;
}
else {
  $Anfangsposition = $_GET['site'];
}

$sql="select blackword from blacklist WHERE blackword LIKE '". $_GET['sort'] ."%' ORDER BY blackword ASC ".
     "limit $Anfangsposition,$Zeilen_pro_Seite";
$result=mysql_query($sql);
$result1=mysql_query("select blackword from blacklist WHERE blackword LIKE '". $_GET['sort'] ."%' ORDER BY blackword ASC ");

$sort=$_GET['sort'];
$Anzahl=mysql_num_rows($result1);

echo "<hr>\n";
echo "<table align=\"center\">\n";
echo "<tr>\n";

$zaehler=0;


while ($row=mysql_fetch_array($result)) {
$zaehler++;
if($zaehler < "2") {
} else{
echo "<tr>";
$zaehler=1;
}

echo "<td class=\"erowcat\">"
.$row ['blackword'].
"</td>\n";



if($zaehler < "2") {
} else{
echo "</tr>\n";
$zaehler=1;
}
}

echo "  </tr>\n";
echo "</table>\n";

echo "<hr>\n";

echo "<table align=\"center\">\n";
echo "  <tr>\n";
echo "    <td>\n";


if($Anfangsposition > 0) {
  echo "<a href='blacklist.php?list=$optlist&sort=$sort&site=0'> [erste]</a>";
  $back=$Anfangsposition-$Zeilen_pro_Seite;
  if($back < 0) {
    $back = 0;
  }
  echo "<a href=\"blacklist.php?list=$optlist&sort=$sort&site=$back\"> [zur&uuml;ck]</a>";
 }

if($Anzahl>$Zeilen_pro_Seite) {
  $Seiten=intval($Anzahl/$Zeilen_pro_Seite);
  if($Anzahl%$Zeilen_pro_Seite) {
    $Seiten++;
  }
}
for ($i=1;$i<=$Seiten;$i++) {
  $fwd=($i-1)*$Zeilen_pro_Seite;
  if($fwd == $Anfangsposition) {
    echo "<b> $i  </b>";
  }
  else {
    echo "<a href=".$PHP_SELF."?list=$optlist&sort=$sort&site=".$fwd.""."> $i</a>  ";
  }
}

if($Anfangsposition < $Anzahl-$Zeilen_pro_Seite) {
  $fwd=$Anfangsposition+$Zeilen_pro_Seite;
  echo "<a href=\"blacklist.php?list=$optlist&sort=$sort&site=$fwd\"> [weiter]</a>";
  $fwd=$Anzahl-$Zeilen_pro_Seite;
  echo "<a href=\"blacklist.php?list=$optlist&sort=$sort&site=$fwd\"> [letzte]</a>";
}

echo "    </td>\n";
echo "  </tr>\n";
echo "</table>\n";