Ungewollter Eintrag in Datenbank warum?

siros

Mitglied
Hallo alle zusammen!

Ich bin gerade am Shop basteln und das ist auch das erste mal das ich mich mit dem Mysql genauer auseinandergesetzt.

Mein Problem ist das ich andauernd einen Lehren Eintrag in der DB habe wen ich die Seite aufrufe oder Aktualisiere.
Soll aber erst einen Eintrag geben wen ich Daten eintragen will.

Na vielleicht ist einer so lieb von euch und hold den Wurm aus dem Script.

PHP:
<form name="eingabe" action="auslesen.php" method="post">
Titel<input name="titel" type="text"><br>
Beschreibung<input name="description" type="text"><br>
€<input name="price" type="text"><br>
Bild Groß<input name="img_url" type="text"><br>
Bild Klein<input name="thumb_url" type="text"><br>
Angebote:<input name="special" type="checkbox" value="1" ><br>
Categorie:<br>
licht<input name="cat_id" type="checkbox" value="1"><br>
lichtobjekte<input name="cat_id" type="checkbox" value="2"><br>
schmuck<input name="cat_id" type="checkbox" value="3"><br>
wohnaccessoires  	<input name="cat_id" type="checkbox" value="4"><br>
<input type="reset" value="Reset">
<input type=submit value="Eintaragen">
</form>

PHP:
<?

$id = "root";
$pw = "";
$host = "localhost";
$database = "shop_de";

?>
<?php 
$id = $HTTP_POST_VARS["id"];
$titel = $HTTP_POST_VARS["titel"];
$description = $HTTP_POST_VARS["description"];
$price = $HTTP_POST_VARS["price"];
$img_url = $HTTP_POST_VARS["img_url"];
$thumb_url = $HTTP_POST_VARS["thumb_url"];
$special = $HTTP_POST_VARS["special"];
$cat_id = $HTTP_POST_VARS["cat_id"];


$eintrag = "INSERT INTO pwh_articles (ID, titel, description,
  price, img_url, thumb_url, special, cat_id) VALUES ('$id', '$titel',
  '$description', '$price','$img_url','$thumb_url','$special','$cat_id')";
  
$eintragen = mysql_query($eintrag);
?>
 
Zuletzt bearbeitet:
Setz in dein Formular noch ein hidden Feld und überprüfe erst, ob die variable übergeben ist.

Beispiel

Formular:
Code:
<input type="hidden" value="1" name="go">

PHP:
PHP:
if ($_POST['go'] == 1) 
{
was php mit dem Formular machen soll
} else {
Ausgabe wenn Formular nicht verschickt wurde
}
 
Zurück