my code returns success, but it does not insert the record to the table "bekuldottkerdesek". What is causing the problem?
Even select command fails, when I start to echo some records from the table.
This is how the table looks: imgur
<?php
$servername = "***";
$username = "***";
$password = "***";
$dbname = "***";
$conn = new mysqli($servername, $username, $password, $dbname);
date_default_timezone_set('Europe/Bucharest');
$current_date = date("Y-m-d H:i:s");
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$check="SELECT * FROM bekuldottkerdesek WHERE kerdes = '$_POST[kerdes]'";
$res = mysqli_query($conn,$check);
if($res->num_rows){
header("Location: /bekuld.php?hiba=1");
}
else
{
$var1 = isset($_POST['at']) ? 1 : 0;
$var2 = isset($_POST['bt']) ? 1 : 0;
$var3 = isset($_POST['ct']) ? 1 : 0;
$sql = "INSERT INTO bekuldottkerdesek (datum, kerdes, a, b, c, at, bt, ct)
VALUES ('$current_date', '$_POST[kerdes]', '$_POST[a]', '$_POST[b]', '$_POST[c]', $at, $bt, $ct)";
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}
header("Location: /bekuld.php?hiba=2");
}
$conn->close();
?>