PDA

View Full Version : how to do form to html



neuromix
August 3rd, 2002, 04:46
newbie here, just wondering if anyone knows how i can do this.

i want the user to be able to fill out a form, then when submitted, it will write to a html page in the template i want it to be in, something very similar to comments.

yarassa
August 3rd, 2002, 14:35
use this:

I think only form has name, e-mail and comment:



<?

$newdate = date (d/m/Y);

// First we take the comments and number before adding new comment
$openfile = fopen ("comments.txt", "r");
$onceadd = fread ($openfile, filesize ("comments.txt"));
fclose ($openfile);

$opennumber = fopen ("number.txt", "r");
$lastnumber = fread ($opennumber, filesize ("number.txt"));
fclose ($opennumber);

// And now we add the new comment
$commentfile = fopen ("comments.txt", "w");
$numberfile = fopen ("number.txt", "w");

if ($s==11) { // Change this to 21 if you want 20 comments. And after 20 comments last comments will be deleted ( but all ).
$newest = '\n- '.$comment.' <br> Added by: <a href="mailto: '.$email.'">'.$name.'</a> on '.$newdate.'<br><br>';
$s = 1
fwrite ($commentfile, $newest);
fwrite ($numberfile, $s);
}else{
$newest = '\n- '.$comment.' <br> Added by: <a href="mailto: '.$email.'">'.$name.'</a> on '.$newdate.'<br><br>'.$onceadd;
$s++;
fwrite ($commentfile, $newest);
fwrite ($numberfile, $s);
}
fclose ($commentfile);
fclose ($numberfile);
?>


I only do this for you. These are the form inputs:
<form action="anything.php" method="post">
<input type="text" name="name"><br>
<input type="text" name="email"><br>
<input type="text" name="comments"><br>
<input type="submit" value="Add It!">
</form>

Dont forget to create 0 bytes comment.txt and number.txt . And this program has no security. If you want do this yourself.

It is not matter!!! :)

ansa
August 4th, 2002, 02:06
thankfully (and no disrespect to yarassa) there are much easier ways to do this. PM me, and we can discuss exactly what language you need, and where your files are, etc, and then i'll get it coded for you if you like

cheers,
Andy.