[英]Can I set an html text field value to a variable, so it saves the previously entered content?
<?php $content = $_POST['content']?>
<p>Page title: <input type='text' name='title' value="<?php $content ?>"/></p>
<?php $content = $_POST['content']?>
<p>Page title: <input type='text' name='title' value="<?php $content ?>"/></p>
I would like to know if something like this is either possible, or if theres a work around, like a way to save the previously entered content as the value. 我想知道这样的事情是否可行,或者是否可以解决,比如将以前输入的内容保存为值的方法。 Any help is greatly appreciated.
任何帮助是极大的赞赏。
Save it in a session and retrieve it anywhere using the key just start the session like below : 将它保存在会话中并使用密钥在任何地方检索它,只需启动会话,如下所示:
<?php
// Start the session
session_start();
?>
<?php
// Set session variables
$content = $_POST['content']
$_SESSION["content"] = $content;
echo "Session variables are set."+ $_SESSION["content"] ;
?>
If you want to do it with PHP you need to learn about sessions and cookies . 如果你想用PHP做,你需要了解会话和cookie 。
Here is an example with cookies 这是一个cookie的例子
<?php
start_session();
if(isset($_GET["title"])) {
if(isset($_SESSION["oldTitle"])) {
// do what you want to do
}
// update to the new value
$_SESSION["oldTitle"] = $_GET["title"];
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.