It wont submit in the sql database can someone help me?

<?php
$connect = mysqli_connect("localhost","id12302950_admin","test321","id12302950_gebruikers");
if (!$connect) {
    echo "not connected";
} else {
    echo "connected succesfully";
}

if (isset($_POST['Vulgebruikerdetails'])) {

    $naam = $_POST['Naam'];
    $Adres = $_POST['Adres'];
    $Telefoon = $_POST['Telefoon'];
    $Email = $_POST['Email'];

if(!empty($naam) && !empty($Adres) && !empty($Telefoon) && !empty($Email) ) {


        $sql = "INSERT INTO `insertdeleteedittable`(`Naam`, `Adres`, `Telefoon`, `Email`) 
                                        VALUES ('$naam'],'$Adres','$Telefoon','$Email')";

$qry = mysqli_query($connect, $sql);
        if ($qry) {
            echo "Succesvol ingevoerd.";
        }
        else {
            echo "Alle velden moeten ingevuld worden.";
        }
    }

}
?>

<!doctype html>
<html>
<head>
    <title></title>
</head>
<body>
<form action="" method="POST">

<input type="text" name="Naam"><br ><br >
<input type="text" name="Adres"><br ><br >
<input type="text" name="Telefoon"><br ><br >
<input type="email" name="Email"><br ><br >
<input type="submit" name="Vulgebruikerdetails" value="Opslaan">
</form>
</body>
</html>

Please place your code between the code tags so that we can read it

<html>
<?php
$connect = mysqli_connect("localhost","id12302950_admin","test321","id12302950_gebruikers");

if (isset($_POST['Vulgebruikerdetails'])) {

    $naam = $_POST['Naam'];
    $Adres = $_POST['Adres'];
    $Telefoon = $_POST['Telefoon'];
    $Email = $_POST['Email'];

if(!empty($naam) && !empty($Adres) && !empty($Telefoon) && !empty($Email) ) {


        $sql = "INSERT INTO `insertdeleteedittable`(`Naam`, `Adres`, `Telefoon`, `Email`) 
                                        VALUES ('$naam'],'$Adres','$Telefoon','$Email')";

$qry = mysqli_query($connect, $sql);
        if ($qry) {
            echo "Succesvol ingevoerd.";
        }
        else {
            echo "Alle velden moeten ingevuld worden.";
        }
    }

}
?>

<!doctype html>
<html lang="nl">
<head>
    <title></title>
</head>
<body>
<form action="" method="POST">

    <label>
        <input type="text" name="Naam">
    </label><br ><br >
<input type="text" name="Adres"><br ><br >
<input type="text" name="Telefoon"><br ><br >
<input type="email" name="Email"><br ><br >
<input type="submit" name="Vulgebruikerdetails" value="Opslaan">
</form>
</body>
</html>

There is a lot to do in this script even while it is short.

  • checking if your form has been submitted could easily be done with
if($_SERVER['REQUEST_METHOD'] == 'POST') {
    ...
}
  • remove the whole action attribute
  • give your mysql table a better name. something like “contact_requests” would make sense.
  • your query is not valid
  • if your query fails you could use mysqli_error($connect) to display the error

I checked the database and it is still not submitting, I need to get this fixed fast. What can I do to get it to work?

If you turned error reporting on, you would see there are issues with your insert statement.

1 Like
Sponsor our Newsletter | Privacy Policy | Terms of Service