I am trying to generate an HTML page using data gathered in a form on another page. I have this tag on the html page with the form:
<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>
and on the html_data.php page I have the following:
<?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();
?>
This should do what I am asking it to do. The form submits with no problem, but I cannot find the page once it submits. Any idea what I need to change?
In your form
Change from
<textarea name="Team-members" rows=10 cols=40 type="text">to
<textarea name="Team_members" rows=10 cols=40 type="text">In your html_data.php
Change from
<?php echo $Team-members; ?>to
<?php echo $Team_members; ?>There is obviously an issue with the dash between Team and members.
PHP is treating the hyphen as a mathematical operation, being a minus.
I.e.: Team minus members
Then, if you wish to
echothe data to screen after submission, addunderneath
ob_end_clean();This worked for me.