Hoi
Ich kenne mich nicht wirklich gut aus mit php
habe ein tutoreal gemacht
und wolte aus eigener hand von einem anderen tutoreal ein spam schutz rein hauen.
die abfrage ob die spam richtig eingegeben wurde funzt leider ned ich weis ned was ich vergessen habe ich denke da fehlt was
villt kan es sich mal jemand hier anschauen und mir zeigen was falsch ist was fehlt???
...
das gb leuft auf meiner hp:
http://tue-hauptclan.eu
PHP-Code:
<?php
error_reporting(E_ALL);
ini_set('display_errors', 1);
$db = @new mysqli('localhost', '*****', '*****', '*****');
if (mysqli_connect_errno()) {
die('Konnte keine Verbindung zur Datenbank aufbauen: '.mysqli_connect_error().'('.mysqli_connect_errno().')');
}
readfile('header.html');
$Zahl_1 = intval(rand(1, 5));
$Zahl_2 = intval(rand(1, 5));
?>
<form action="index.php" method="post">
<table border="0">
<tr>
<td colspan="2">
<p align="center"><b><font color="#FFFFFF">Ins Gästebuch Eintragen</font></font></b></td>
</tr>
<tr>
<td><b><font color="#FFFFFF"><label>Name: </label> </font></font></b></td>
<td><label>
<font color="#FFFFFF">
<input name="Autor" style="width:186px" /><b></font></b></font></label></td>
</tr>
<tr>
<td><b><font color="#FFFFFF"><label>Text: </label> </font></font></b></td>
<td><label>
<font color="#FFFFFF">
<textarea name="Inhalt" rows="6" cols="40" style="font-weight: 700"></textarea><b></font></b></font></label></td>
</tr>
<tr>
<td><b><font color="#FFFFFF"><label><strong>Wieviel ist <?php echo $Zahl_1; ?> plus <?php echo $Zahl_2; ?>?:</strong></label> </font></font></b></td>
<td><label>
<input name="Antwort" type="hidden" id="Antwort" value="<?php echo md5(( $Zahl_1 + $Zahl_2 )); ?>"/>
<font color="#FFFFFF">
<input name="arithmetic" type="text" id="arithmetic" style="width:186px" onfocus="if(this.value=='Das Ergebnis bitte hier hinein...')this.value=''" onblur="if(this.value=='')this.value='Das Ergebnis bitte hier hinein...'" value="Das Ergebnis bitte hier hinein..."/></font></td></label>
</tr>
<tr>
<td>
<b><font color="#FFFFFF">Mögliche Aktionen:</font></b></td>
<td>
<font color="#FFFFFF">
<input type="submit" name="formaction" value="Eintragen" style="font-weight: 700" /> <input type="reset" name="Löschen" value="Löschen" style="font-weight: 700" /><b></font></b></font></td>
</tr>
</table>
</div>
</form>
<?php
if ('POST' == $_SERVER['REQUEST_METHOD']) {
if (!isset($_POST['Autor'], $_POST['Inhalt'], $_POST['Antwort'], $_POST['formaction'])) {
die ('Benutzen sie nur Formulare von der Homepage.');
}
if (('' == $autor = trim($_POST['Autor'])) or
('' == $inhalt = trim($_POST['Inhalt'])) or
('' == $antwort = trim($_POST['Antwort']))) {
die ('Bitte füllen sie das Formular vollständig aus.');
}
if ('echo md5(( $Zahl_1 + $Zahl_2 )); ' != $antwort) {
die ('Sie müssen die Frage richtig beantworten.');
}
$sql = 'INSERT INTO
Guestbook(Autor, Datum, Inhalt)
VALUES
(?, NOW(), ?)';
$stmt = $db->prepare($sql);
if (!$stmt) {
die ('Es konnte kein SQL-Query vorbereitet werden: '.$db->error);
}
$stmt->bind_param('ss', $autor, $inhalt);
if (!$stmt->execute()) {
die ('Query konnte nicht ausgeführt werden: '.$stmt->error);
}
echo '<p class="info">Gästebucheintrag hinzugefügt. <a href="index.php">Zurück zum Gästebuch</a>.</p>';
} else {
$sql = 'SELECT
Datum,
Autor,
Inhalt
FROM
Guestbook
ORDER BY
Datum DESC';
$result = $db->query($sql);
if (!$result) {
die('Der Query konnte nicht ausgeführt werden: '.$db->error);
}
if ($result->num_rows) {
while ($row = $result->fetch_assoc()) {
echo '<div class="beitrag">'."\n";
echo ' <span class="autor">'.htmlspecialchars($row['Autor'])."</span>\n";
echo ' <span class="datum">'.$row['Datum']."</span>\n";
echo " <p>\n";
echo nl2br(htmlspecialchars(preg_replace('~\S{30}~', '\0 ', $row['Inhalt'])));
echo " </p>\n";
echo "</div>\n";
}
} else {
echo '<p class="info">Es sind keine Gästebucheinträge vorhanden</p>';
}
}
readfile('footer.html');
?>
Währe cool wen das sich jamannd angugt mit mier