Formulardaten werden nicht in die Datenbank eingetragen

Einklappen
X
 
  • Filter
  • Zeit
  • Anzeigen
Alles löschen
neue Beiträge

  • Formulardaten werden nicht in die Datenbank eingetragen

    Hallo,
    habe folgendes Problem. Habe ein Formular, das seine Angaben in eine MySQL Datenbank eintragen soll. Hier die index.php:
    PHP-Code:
    <html>
    <head>
    <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
    <title>Informatik Hausaufgabe</title>
    </head>

    <table width="401" border="1" cellpadding="0" cellspacing="0">
      <!--DWLayoutDefaultTable-->
      <tr>
        <td width="397" height="499" colspan="2"><table width="100%" border="0" cellpadding="0" cellspacing="0">
            <!--DWLayoutTable-->
            <tr>
              <td height="25" colspan="2" valign="top"><div align="center">Pers&ouml;nliche Angaben</div></td>
        </tr>
            <tr>
              <td height="13" colspan="2" valign="top"><!--DWLayoutEmptyCell-->&nbsp;</td>
            </tr>
            <tr>
              <td width="165" height="500" valign="top"><div align="center">
                  <table width="165" height="340" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td height="30">Vorname:</td>
                    </tr>
                    <tr>
                      <td height="30">Nachname:</td>
                    </tr>
                    <tr>
                      <td height="30">&nbsp;</td>
                    </tr>
                    <tr>
                      <td height="25">Geschlecht:</td>
                    </tr>
                    <tr>
                      <td height="25"><label></label></td>
                    </tr>
                    <tr>
                      <td height="25"><label></label></td>
                    </tr>
                    <tr>
                      <td height="25"><label></label></td>
                    </tr>
                    <tr>
                      <td height="30">Geburtsdatum:                  </td>
                    </tr>
                    <tr>
                      <td height="25">&nbsp;</td>
                    </tr>

                    <tr>
                      <td valign="top">Kommentar: </td>
                    </tr>
                  </table>
                  <p align="left">                <br>
                    <br>
          <br>
                  </p>
              </div></td>
              <td width="233" height="500" valign="top"><form action="insert.php" method="post" name="Anmeldung" id="Anmeldung">
                   <table width="233" height="340" border="0" cellpadding="0" cellspacing="0">
                    <tr>
                      <td height="30"><input name="name" type="text"></td>
                    </tr>
                    <tr>
                      <td height="30"><input name="vorname" type="text"></td>
                    </tr>
                    <tr>
                      <td height="30">&nbsp;</td>
                    </tr>
                    <tr>
                      <td height="25"><input type="radio" name="Optionsschaltergruppe1" value="optionsschalter">
                        <label>männlich</label></td>
                    </tr>
                    <tr>
                      <td height="25"><input type="radio" name="Optionsschaltergruppe1" value="optionsschalter">
                        <label>weiblich</label></td>
                    </tr>
                   <tr>
                      <td height="25">&nbsp;</td>
                    </tr>
                    <tr>
                      <td height="30">
                      <select name="Tag">


                                     <?
                          for ($i=1;$i<32;$i++)
                        {
                          echo('<option>'.$i.'</option>');
                        }
                    ?>
                        </select>

                        <select name="Monat">
                    <?
                          for ($i=1;$i<13;$i++)
                        {
                          echo('<option>'.$i.'</option>');
                        }
                    ?>
                        </select>


                        <select name="Jahr">
                    <?
                          for ($i=1900;$i<2000;$i++)
                        {
                          echo('<option>'.$i.'</option>');
                        }
                    ?>

                        </select>
                        </td>
                    </tr>
                    <tr>
                      <td height="25">&nbsp;</td>
                    </tr>
                    <tr>
                      <td height="95" valign="top"><textarea name="textarea"></textarea></td>
                    </tr>
                  </table>
                  <p>
                    <input type="reset" name="Submit" value="Abbrechen">
                    <input type="submit" name="Submit" value="Abschicken">
                    <br>
                    <br>
    </p>
                  </form></td>
            </tr>
        </table></td>
      </tr>
    </table>
    </body>
    </html><?

                        include('insert.php');

                    ?>
    und hier die insert.php
    PHP-Code:

    <?php
    $server    
    "localhost";
    $user    "XXXX";
    $pass    "XXXX";
    $database "skyjack";
    $table    "informatikHA";

    $verbindung mysql_connect($server$user$pass)
        or die (
    "verbindung zu sql geht nicht");

    mysql_select_db($database$verbindung);

    $sql "INSERT INTO $table (id, Vorname, Nachname, Geburtsdatum, Kommentar)
            VALUES ('"
    $_POST['id']."', '"$_POST['Vorname']."', '"$_POST['Nachname']."', '"$_POST['Geburtsdatum']."', '"$_POST['Kommentar']."')";

    $ausgabe "gespeichert!";

    sql_query($sql) or die ("sql eintrag fehler");

    mysql_close($verbindung);
    echo 
    $ausgabe;

    ?>
    Ich hoffe mir kann jemand von euch helfen. Vielen Dank schon mal für die Antworten

    MfG

    Skyjack

  • #2
    Aha, das ist ja schön.

    Regeln lesen, code umbrechen, problem beschreiben, fehlermeldung posten-

    BTW: du bist nicht der erste mit so einem Problem.

    Kommentar

    Lädt...
    X