请原谅我的标题,解释我的问题有点困难。所以就在这里。在http://appsolute.vacau.com/cms我在 textarea 中有一个变量。您可以从一开始就看到变量的输出。更新提交表单的文本就是更新变量。到目前为止一切都是正确的,对吧?提交表单时,页面会重新加载,但所有内容都来自变量的先前内容。但是在检查时,变量 WAS 更新了。即使你刷新页面。那么为什么我在提交表单后看不到变量的实际值呢?希望它是有道理的...
<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>