Php 如何创建从txt文件反馈数据的textarea
晚上好。 首先,我为自己刚刚接触web开发领域而道歉。我正在尝试创建一个可以输入文本的文本区域,刷新页面后,该文本将显示在文本区域上方,以便我可以引用它 我正在分阶段工作,到目前为止,我真的很难将用户输入从html转换到php,然后重新插入到该页面上。 有人能解释一下怎么做吗 我的代码包括在下面Php 如何创建从txt文件反馈数据的textarea,php,html,Php,Html,晚上好。 首先,我为自己刚刚接触web开发领域而道歉。我正在尝试创建一个可以输入文本的文本区域,刷新页面后,该文本将显示在文本区域上方,以便我可以引用它 我正在分阶段工作,到目前为止,我真的很难将用户输入从html转换到php,然后重新插入到该页面上。 有人能解释一下怎么做吗 我的代码包括在下面 <!DOCTYPE HTML> <html> <head> <meta charset="UTF-8"> <title>HTML php<
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>HTML php</title>
<link href="" rel="stylesheet" type="text/css" media="screen"> <!-- link to CSS sheet -->
</head>
<body>
<h1>HTML php</h1>
<?php
//***************************************
// Gather Data from Form
//***************************************
$HTMLNotes = $_POST['HTML_notes'];
$DOCUMENT_ROOT = $_SERVER['DOCUMENT_ROOT'];
$filename = $DOCUMENT_ROOT.'First Website/HTML/Html_Notes.txt';
//***************************************
//Add Name Information to File
//***************************************
$fp = fopen($filename, 'a'); //opens the file for appending
$output_line = $HTMLNotes.'|'."\n";
fwrite($fp, $output_line);
fclose($fp);
print "<h3>$HTMLNotes Added to File</h3>";
?>
<div class="container clearfix">
<?php
//--------------------------------------
//Reading info from file
//--------------------------------------
//Table of names --------------------------
$display = "";
$line_ctr = 0; //line counter
$fp = fopen($filename, 'r'); //opens the file for reading
while(true)
{
$line = fgets($fp); //gets one line at a time
if (feof($fp)) //eof = end of file
{
break;
}
$line_ctr++;
$line_ctr_remainder = $line_ctr % 2; //modulus of 2 and returns the remainder so even will always return 0
list($HTMLNotes) = explode('|', $line);
print "<p>".$HTMLNotes."</p>";
print "</tr>\n"; //added newline
//added newline
}
fclose ($fp );
print $display; //this prints the table rows
?>
</div>
</body>
</html>
HTML php
HTML php
这就是PhP,下面是HTML。对不起,这里一团糟
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8">
<title>HTML</title>
<link href="../CSS/Style.css" rel="stylesheet" type="text/css" media="screen"> <!-- link to CSS sheet -->
<link href="../CSS/normalise.css" rel="stylesheet" type="text/css" media="screen"> <!-- link to normalised CSS form, this keeps standard normal elements for browsers. -->
</head>
<body>
<header>
<div class="container clearfix">
<a href="../index.html" title="Return to home" id="Logo">
<img src="../IMAGES/Logo.gif" alt="Logo">
</a>
<nav>
<ul>
<li><a href="../index.html">HOME</a></li>
<li><a href="HTML.html">HTML</a></li>
<li><a href="CSS.html">CSS</a></li>
<li><a href="LINKS.html">LINKS</a></li>
</ul>
</nav>
</div> <!-- end div container -->
</header>
<div id="mainheader"> <!--hero -->
<div class="container clearfix">
<div id="Title">
<h1>HTML Resources and References</h1>
</div> <!--end of title -->
<img src="../IMAGES/BigHTML.png" alt="Large HTML Logo" id="HTML-image">
</div> <!-- end of container -->
</div> <!--end of mainheader -->
</header> <!--end of header -->
<div id="content" class="container clearfix">
<form method="post" action="HTML.php">
<p>
HTML notes:<br />
<textarea name="HTML_notes" rows="7" cols="130">
</textarea>
</p>
<p>
<input type="submit" class="Btn Btn-small" value="Submit Information">
</p>
</form>
</div> <!-- end of content -->
<div id="LowerSection">
<div class="container clearfix">
<h4>Sign up on the website to find out more information</h4>
<form>
<input type="email" placeholder="Enter your email here">
<input type="submit" class="Btn Btn-small" value="Sign up">
</form>
</div> <!-- end of container-->
</div> <!-- end of LowerSection -->
<footer>
<div class="container clearfix">
<p id="copyright">Copyright © 2015 AaronMurphy</p> <!-- using the & with a word reduces errors and creates symbols -->
<nav>
<ul>
<li><a href="../index.html">HOME</a></li>
<li><a href="HTML.html">HTML</a></li>
<li><a href="CSS.html">CSS</a></li>
<li><a href="LINKS.html">LINKS</a></li>
</ul>
</nav>
</div> <!-- end of conatiner -->
</footer>
</body>
</html>
HTML
HTML资源和参考
HTML注释:
在网站上注册以了解更多信息
版权与复制;2015 AaronMurphy
哪个位不工作?如果您想让textarea内容从php返回到表单页面,请将表单html代码放在php文件中,并添加从txt文件读取的php代码,就像您所做的那样。感谢您的快速响应,我想我想要的是能够在我的html网页上的textarea中输入信息。当我刷新页面时,我刚刚输入的信息会出现在div的文本区域上方,我想这与我正在输入的注释框现在的工作方式类似。如果你能举例说明,我不是100%确定该怎么做?我理解这个理论,但只是不知道在哪里以及如何将其应用到我的代码中