0

I hope someone can help me. I can use some PHP, but i'm not an expert. Here's the deal.

I have created a html form(form.html) Now i want the formular.php-output to be saved as a unique html-file ex. formular.php?id=00000001. The next time someone is submitting the form, the file has another name ex. formular.php?id=00000002. Or maybe as an file.html? But how do i do that?

form.html:

form action="formular.php" method="post"

.
.
input type="text" value="Skriv navnet på FB-siden" name="mit_tekst_felt" size="55"
.
.
.
.               

input type="submit" value="Generer konkurrencebetingelser"


Thanks in advance if you guys can help me.

4
  • Please begin with reading the basics: php.net/manual/en/tutorial.forms.php Commented Jul 19, 2014 at 9:59
  • Live example:[link]wemakeitsocial.free4u.dk/konkurrencebetingelser Commented Jul 19, 2014 at 10:11
  • What's the live example for? Commented Jul 19, 2014 at 10:14
  • That's what i've been making so far. I now want the output, when you hit "Generer konkurrencebetingelser", to be saved as an unique file. Either as ex. formular.php?id=00000001 or as an html-file. Commented Jul 19, 2014 at 10:18

1 Answer 1

0

In konbet/formular.php you could do something like:

// Script Start
ob_start();

// You former Script Code
// ...

// Script End
$html = ob_get_clean();
$file = "/path/to/file_".md5($html).".html"
file_put_contents($file, $html);
echo $html;

The md5 is giving you a unique name if the html content differs. If you want to save each submit (even each one with a blank form) you can add the timestamp with microseconds to the file name.

If you really need consecutive numbers, then you should save your last number in another file, count it up, check if new file really doesn't exist, save new file and the file with your new number.

Sign up to request clarification or add additional context in comments.

1 Comment

You are welcome. Please clearify your question next time: the form.html had nothing to do with your problem (and was not valid html, so my first comment came up...). But we did it :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.