Re: [PHP] create file after form completion

2011-10-29 Thread Stephen

On 11-10-29 12:38 PM, 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.

This is a subject that will take a bit of your time to understand. This 
web site is a good place to start:


http://www.tizag.com/phpT/examples/formex.php

You need to create an HTML form in your web page.

The form specifies the PHP file that is the form handler. When the 
user clicks submit, their web browser calls your file that is the form 
handler and passes to it the data that they entered.


Exactly what your form handler does is up to you. You can:

Respond to the user
Save the data in a file or database
Email the data

Good luck
Stephen

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



Re: [PHP] create file after form completion

2011-10-29 Thread Ashley Sheridan
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
 titleThis is amazing Mr. $name/title
   /head
   body
 pMy 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




Re: [PHP] create file after form completion

2011-10-29 Thread Pau
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(exam...@example.com,
  New registration, 
time:   $time
ip-adress:  $ip

html
 head
   titleThis is amazing Mr. $name/title
 /head
 body
   pMy 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
   titleThis is amazing Mr. Paul/title
 /head
 body
   pMy 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 a...@ashleysheridan.co.uk 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
 titleThis is amazing Mr. $name/title
   /head
   body
 pMy 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



Re: [PHP] create file after form completion

2011-10-29 Thread Ashley Sheridan
On Sat, 2011-10-29 at 19:52 +0200, Pau wrote:

 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(exam...@example.com,
   New registration, 
 time:   $time
 ip-adress:  $ip
 
 html
  head
titleThis is amazing Mr. $name/title
  /head
  body
pMy 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
titleThis is amazing Mr. Paul/title
  /head
  body
pMy 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 a...@ashleysheridan.co.uk 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
  titleThis is amazing Mr. $name/title
/head
body
  pMy 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
 
 


Please try not to top post.

To create a file, look into the fopen() function on php.net, which has
plenty of examples on how to create a file. Creating one with a new name
to avoid conflicts with other files on the system is a little more
tricky, but it's not too difficult.

What I asked in my earlier post though was whether you really need to
create a new HTML file from PHP or you just need to display the results
to the user?

-- 
Thanks,
Ash
http://www.ashleysheridan.co.uk




Re: [PHP] create file after form completion

2011-10-29 Thread Tedd Sperling
On Oct 29, 2011, at 12:38 PM, Pau wrote:
 -snip-
 
 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.

Pau:

http://webbytedd.com/simple-stuff/post/index.php

I leave the header and footer up to you.

Cheers,

tedd


_
t...@sperling.com
http://sperling.com

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



Re: [PHP] create file after form completion

2011-10-29 Thread Pau
Hi,


 Please try not to top post.

sorry, but I do not understand the expression (I am not native, as you
might have guessed). Do you mean not to include the email in my reply?
Sorry about that.


 To create a file, look into the fopen() function on php.net, which has plenty 
 of examples on how to create a file. Creating one with a new name to avoid 
 conflicts with other files on the system is a little more tricky, but it's 
 not too difficult.

I will look into that, thanks.


 What I asked in my earlier post though was whether you really need to create 
 a new HTML file from PHP or you just need to display the results to the user?


I really would like to create the file, if it is not too much trouble.
The user will not get to see the results until the file and contents
are checked.

thanks,

Pau

 --
 Thanks,
 Ash
 http://www.ashleysheridan.co.uk



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



Re: [PHP] create file after form completion

2011-10-29 Thread Tommy Pham
This line is consider 'top post'.  Meaning you're posting on top of the
reply.

On Sat, Oct 29, 2011 at 12:12 PM, Pau vim.u...@googlemail.com wrote:

 Hi,

 
  Please try not to top post.

 sorry, but I do not understand the expression (I am not native, as you
 might have guessed). Do you mean not to include the email in my reply?
 Sorry about that.


Where as this line is bottom posting.  Meaning you'd be posting
bottom/below the reply, which is the preferred method on this list.

Regards,
Tommy