-1

我正在尝试使用在另一个页面上的表单中收集的数据生成一个 HTML 页面。我在 html 页面上有这个标签,格式如下:

<html>
<body>

<meta http-equiv="cache-control" content="private" > 
<link rel="stylesheet" type="type/css" href="vytran_css.css" />


<head> New Product Introduction </head>

<p> In order to begin the process of introducing a new product, please complete
the following form. Once you are satisfied with your responses to the various 
prompts, please click on the submit button at the bottom of the page. If you 
would like to start over, click the Reset button. If you have any questions, 
Please follow the link that says "Help".


<form action="html_data.php" id=from1 method="post"> 
Product Name: 
<input name="Name" size="20" type="text">
<br><br>

Project Lead Name:
<input name="PLname" size="20" type="text"> <br><br>

Team-members: <br>
<textarea name="Team-members" rows=10 cols=40 type="text"> </textarea> <br><br>

Product Type: <br>
<input name="Product Type" size="20" type="text"> <br><br>

Description: <br>
<textarea name="Description" rows=10 cols=40 type="text"> </textarea>
<br>

<br> <br>



<input value="Submit" type="submit" name="formSubmit">
<input value="Reset" type="reset">
<input value="Help" type="button" onclick="window.location.href='problems.html'">
</form>
</p>

</body>
</html>

在 html_data.php 页面上,我有以下内容:

<?php 
    ob_start(); // start trapping output 
    $name = @$_POST['Name']; 
?> 
<html> 
<body> 
<p> 
Product Name: <?php echo $Name; ?><br> 
Project Lead: <?php echo $PLname; ?><br> 
Team Members: <?php echo $Team-members; ?><br> 
Description: <?php echo $Description; ?> 
</p> 
</body> 
</html> 
<?php 
    $output = ob_get_contents();  
    $newfile="output.txt";  
    $file = fopen ($newfile, "w");  
    fwrite($file, $output);  
    fclose ($file);   
    ob_end_clean();  
?> 

这应该做我要求它做的事情。表单提交没有问题,但提交后我找不到页面。知道我需要改变什么吗?

4

1 回答 1

1

以你的形式

从改变

<textarea name="Team-members" rows=10 cols=40 type="text">

<textarea name="Team_members" rows=10 cols=40 type="text">

在你的html_data.php

从改变

<?php echo $Team-members; ?> <?php echo $Team_members; ?>

团队和成员之间的冲刺显然存在问题。

  • PHP 将连字符视为数学运算,即减号。

  • 即:团队减去成员

然后,如果您希望echo在提交后筛选数据,请添加

echo $output;

ob_end_clean();

这对我有用。

于 2012-06-14T16:01:28.167 回答