In Joomla, I am trying to post a form created directly in an article via php DirectPHP and save data to database. I don't know why but sometimes it saves the data and sometimes not. It looks like there was some cache or something because if I get the field value displayed it still shows me the first value of the form I filled out at first. If I make any change to the code (e.g. add one row to echo whatever it works but then again the form displays this last record). Any ideas please (I don't want to use Chronoforms component).
The code in the article:
if($_GET['sent']=="ok")
{
$db = mysqli_connect("localhost", "xxxx", "xxxx", "xxxx") or die("Database not found");
mysqli_query($db, "INSERT INTO subscribe_form VALUES('','".$_GET['email_address']."')");
mysqli_close($db);
$form_sent = 1;
echo "Thank you, your email address was saved.";
}
if($form_sent==0)
{
echo "Enter your email address if you want to get subscribed.";
echo "<form action='index.php' method='get'>";
echo "</br></br>Your email address: <input type='text' name='email_address'/>";
echo "<input type='hidden' name='sent' value='ok'/>";
echo "<input type='hidden' name='option' value='com_content'>";
echo "<input type='hidden' name='Itemid' value='240'>";
echo "<input type='hidden' name='id' value='36'>";
echo "<input type='hidden' name='view' value='article'>";
echo "<input type='submit' name='odeslano' value='SAVE' />";
}
?>