Rok Ivartnik Rok Ivartnik - 4 months ago 18
MySQL Question

how to add php data to mysql then go back to HTML

I am struggling here a little. I have following code which is working. However at the moment i get messege "Connected successfully".

What i would like is when data is sent to mysql database, to go back to "xxx.html" which is my site where user input data.

Thanks in advance!

$conn = new mysqli($servername, $username, $password,$dbname);

// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Connected successfully";
$sql = "INSERT INTO smart_zaposleni (ime, priimek, dopust, kontakt)
VALUES
('$_POST[ime]','$_POST[priimek]','$_POST[dopust]','$_POST[kontakt]')";

if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}$conn->close();

Answer
if ($conn->query($sql) === TRUE) {
echo "New record created successfully";
header( "refresh:10;url=whereever.php" ); 
} else {
echo "Error: " . $sql . "<br>" . $conn->error;
}$conn->close();