I want to call a PHP function that I have on the same page, in the HTML button.
My PHP function:
if(isset($_POST['insert']))
{
insert();
}
function insert()
{
$requete = "INSERT INTO \"event\" (
title,
start,
end,
description
)
VALUES
(
\"$txttitle\",
\"$txtstart\",
\"$txtend\",
\"$txtdescription\"
)";
$resultat = $base_hndl->exec($requete);
return $resultat;
echo "feito";
}
And the HTML button:
<form method="post" action="insert()">
<input type=submit required name='insert' value=save>
</form>
I'm trying to do this. A new button, and a new form to show the data.
function select($dir, $base){
$base_hndl = new SQLite3($dir.$base);
$requete = "SELECT id, title, start, end, description FROM \"event\" ORDER BY id DESC";
$resultat = $base_hndl->query($requete);
$affiche = $resultat->fetchArray();
echo "<br><label><b>ID: $affiche[id]</b></label><br>";
echo "<label><b>Title: $affiche[title]</b></label><br>";
echo "<label><b>Start: $affiche[start];</b></label><br>";
echo "<label><b>End: $affiche[end]</b></label><br>";
echo "<label><b>Description: $affiche[description]</b></label><br>";
}
if(isset($_POST['mostrar']))
{
select($dir, $base); //affiche évènements
}
And the
<input type=submit value=Mostrar name='mostrar' >
Why does not it work? Is it by having two forms?