Excuse me for the title, it was a bit hard to explain my problem. So here it is. On http://appsolute.vacau.com/cms I have a variable in the textarea. You see the output of the variable from start. Updating the text en submitting the form IS updating the variable. Thus far everything is right, right? On submitting the form, the page is reloaded, but all the content is from the previous content of the variable. But when checking, the variable WAS updated. Even if you refresh the page. So why don't I get to see the actual value of the variable after submitting the form? Hope it makes sense...
<html>
<head>
<title>Milan CMS</title><?php
$host = "x";
$dbname = "x";
$username = "x";
$password = "x";
$dbh = new PDO("mysql:host=$host;dbname=$dbname", $username, $password);
$sth = $dbh->prepare("SELECT * FROM milan ");
$sth->execute();
$result = $sth->fetchAll();
?>
</head>
<body>
<?php
var_dump($result);
$myFile = "trainingen.json";
$fh = fopen($myFile, 'w') or die("can't open file");
fwrite($fh, json_encode($result));
fclose($fh);
?>
<form action="<?php echo $_SERVER['PHP_SELF']; ?>" method="post" name="trainingen">
<h3>Trainingen:</h3><p><textarea name="nametrainingen" rows="10" cols="60"><?php echo $result[0]['value']; ?></textarea></p>
<input name="submit" type="submit" value="Verzenden"><input type="reset" value="Veld leeg maken">
</form>
<?php
$invoer = $_POST['nametrainingen'];
if (isset($_POST['submit'])) { //test if submit button is clicked
$sql = "DELETE FROM milan WHERE tag = 'trainingen'";
$sth = $dbh->prepare($sql);
$sth->execute();
$sql = "INSERT INTO milan (tag, value) VALUES ('trainingen', '$invoer')";
$sth = $dbh->prepare($sql);
$sth->execute();
}
?>
</body>
</html>