Jump to content

PHP form processing help!


jin_10

Recommended Posts

Hey,

I have a html form ready. What I want to do is the form to save a seperate html file for each submission with the filename to have the name field value and date field value.

For e.g.

the form has fields for Date, Name and comments.

 

let say jack submits form today then the filename would be '20081010_jack.html'

 

and when george submits the form then the filename would be '20081010_george.html'

 

Thanks in advance for your time.

 

Link to comment
https://forums.phpfreaks.com/topic/127826-php-form-processing-help/
Share on other sites

This is about as basic as I can make an example.  Make sure the directory it's in allows writing of files.

 

form.php

<?php
    if(isset($_POST['name']) && strlen($_POST['name'])>0){
        $file=$_POST['date'].'_'.$_POST['name'].'.html';
        $handle=fopen($file, "w");
        fwrite($handle, $_POST['comments']);
        fclose($handle);
    }
?>
<form action="form.php" method="post">
<input type="text" name="name">
<input type="text" name="date">
<textarea name="comments"></textarea>

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.