0

I am trying to insert form data into a table which was created in phpMyAdmin.

<?php
    $DisplayForm = True;
    if(isset($_POST['submit'])){
        $con = mysqli_connect('127.0.0.1','user','password');
        if(!$con) {
            die('Nicht mit dem Server verbunden' . mysql_error());
        }
        mysqli_select_db($con,"ergebnisse");
        if(!mysqli_select_db($con,'ergebnisse')) {
            echo 'Datenbase nicht ausgewählt. <br/>';
        }
        $sql = "INSERT * INTO 'ergebnisse' ('Ergebnis') VALUES ('$_POST[eingabe]')";
        if(!mysqli_query($con, $sql)){
            echo 'Nicht eingefügt. <br/>';
        }
        $DisplayForm = False;
        echo 'Danke für deine Teilnahme!';
    }
    if ($DisplayForm) {
?>
    <form action="Umfrage.php" method="post">
        <input type="text" name="eingabe">
        <input type="submit" name="submit" value="Absenden">
    </form>
<?php
    }
?>

The code does connect to the server but the following code doesn't work so it doesn't select the database and it doesn't insert the form data.

Francisco
  • 10,918
  • 6
  • 34
  • 45
DustinZ3
  • 1
  • 1

0 Answers0