I'm assuming you don't have a great understanding of either PHP, or HTML forms. As such, this is a complete example. It will create a file called "input.htm" and fill it with the information from the form. It will erase any existing data within the file as well.
PHP Code:
<?php
if(isset($_POST['f_name'])) {
// Below we start off with some HTML
$out = "<html>\n<head>\n<title> Stuff from form </title>\n</head>\n";
$out.= "<body bgcolor=\"#FFFFFF\">\n";
$out.= "<b>Name:</b> ".$_POST['f_name']."<br>\n";
$out.= "<b>Age:</b> ".$_POST['f_age']."<br>\n";
$out.= "<b>Hair Colour:</b> ".$_POST['f_hair']."<br>\n";
$out.= "</body>\n</html>";
// Create / open the file for "w" (writing)
$fp = fopen("input.htm","w");
// Put the contents of $out into the file opened with $fp
fwrite($out,$fp);
// close the file
fclose($fp);
}
?>
Then, just below that, Put this code;
HTML Code:
<html>
<head>
<title> The form </title>
</head>
<body bgcolor="#FFFFFF">
<form method="POST" action="<?php echo $PHP_SELF; ?>">
Your name <input type="text" name="f_name"><br>
Your age<input type="text" name="f_age"><br>
Your hair colour<input type="text" name="f_hair"><br>
<input type="submit" value="save info"><br>
</form>
<a href="input.htm" target="_blank">Read the input.htm file</a>
__________________
Theres 10 types of people; those who understand binary, and those who don't.
webmaster and webdeveloper resources, Please login or register to view this content. Registration is FREE
Last edited by webwoRRks; 08-08-2004 at 05:18 PM..
Reason: typo
|