對不起,我很難解釋我的問題。所以在這裏。在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>
:1.負荷的舊數據,2 prentate舊日期,3.添加新的數據,我usaly處理_POST數據首先,在呈現數據之前,所以當我做取回時,新的數據被存儲在數據庫中 –