On my site you can insert new photo albums from the ACF. I created a table in the database that contains the album information, such as name, location, date, and so on. But I have no idea how to enter this album information into the database.
I think the insertion code is like this, but I do not know how to relate it to ACF.
<?php
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "bd";
$conn = new mysqli($servername, $username, $password,$dbname);
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
echo "Conectado!";
$nome_album = $_POST['nome_album']; //Seria o nome que o usuário adiciona no form do ACF
$local_album = $_POST['local_album'];
$data_album = $_POST['data_album'];
$query = "INSERT INTO albums (nome_album, local_album, data_album)
VALUES ('$nome_album', '$local_album', '$data_album')";
if ($conn->query($query) === TRUE) {
echo "cadastro realizado com sucesso";
} else {
echo "Error: " . $query . "<br>" . $conn->error;
}
$conn->close();
?>