Re: create file after form completion

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hello,

thanks for your answers.

I do have a form already and I am using it to mail the results:

------------------------
<?php
//include
//<?php

$HTTP_POST_VARS = $_POST;

$time = date("G:i:s");
$ip = getenv('REMOTE_ADDR');


$vorname = $HTTP_POST_VARS['vorname'];
$nachname = $HTTP_POST_VARS['nachname'];
$post = $HTTP_POST_VARS['post'];




mail("example@xxxxxxxxxxx",
  "New registration", "
time:           $time
ip-adress:      $ip

<html>
 <head>
   <title>This is amazing Mr. $name</title>
 </head>
 <body>
   <p>My surname is $surname and my address $post</p>
 </body>
</html>

");

?>
-----------------------

Instead of this, I would like to dump the results into a file, ideally
with a random name, taken from e.g. $$ in a specific directory

Something like

results/2345.html

with 2345.html

<html>
 <head>
   <title>This is amazing Mr. Paul</title>
 </head>
 <body>
   <p>My surname is Smith and my address Example Street 34</p>
 </body>
</html>

But I have no idea of how to tell php to create a file with the values
from the user.

thanks!
On 29 October 2011 19:27, Ashley Sheridan <ash@xxxxxxxxxxxxxxxxxxxx> wrote:
>
> On Sat, 2011-10-29 at 18:38 +0200, Pau wrote:
>
> Dear all,
>
> I am looking for information on how to have a file created after a
> user has hit a submit on a registration form.
>
> I want to use the variables typed in by the user to automatically
> create a web page with those values.
>
> In the registration form I have
>
> $name = $HTTP_POST_VARS['name'];
> $surname = $HTTP_POST_VARS['surname'];
> $post = $HTTP_POST_VARS['post'];
>
> and I would like to create an html document using those (and other) values:
>
> <html>
>   <head>
>     <title>This is amazing Mr. $name</title>
>   </head>
>   <body>
>     <p>My surname is $surname and my address $post</p>
>   </body>
> </html>
>
> after the form has been completed.
>
> I am a newbie to php and I have been trying to get that information
> somewhere, but I was not successful.
>
> A little help would be appreciated. In particular an example would be wonderful.
>
> Thanks.
>
>
> Instead of trying to actually create the file, why don't you pass those values across dynamically? In-fact, one PHP script could do the whole job:
>
> <?php
> if(isset($_POST['name']))
> {
>     $name = htmlspecialchars($_POST['name']);
>
>     echo "Hello $name";
> }
> else
> {
>     // your form here
> }
>
> --
> Thanks,
> Ash
> http://www.ashleysheridan.co.uk
>
>

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux