Page 1 of 1

want store value into a data file from a Form

Posted: Mon Sep 09, 2002 6:53 am
by sujata ghosh
hi!

i have a file-download form made in html, which take user input and validate them and reffer back those values to a php file. that file store all data into different variables, start download the file and send me a mail with all user's data.

i want to store those value into a dat file or text file along with these tasks, which it is currently doing. can any one tell me how to store values into dat file using php? any site name or example coding will be appreciated.

sujata.

Posted: Mon Sep 09, 2002 7:15 am
by m3mn0n
http://www.php.net

research the following commands:

fopen()
fwrite()
fclose()

Posted: Mon Sep 09, 2002 7:48 am
by Takuma
You could use "fput()"

Posted: Mon Sep 09, 2002 9:19 am
by m3mn0n
yea that too :wink:

Posted: Mon Sep 09, 2002 9:34 am
by mikeq
it is fputs() and it is just an alias for fwrite()

Posted: Tue Sep 10, 2002 1:29 am
by sujata ghosh
thanks to both for your help.

here is that code that i am using. it giving permission problem. i think i have done mistake, please point out that.

Code: Select all

<?php

//Check input
  if(isset($HTTP_POST_VARS&#1111;"Name"]))&#123;  
    $Name = $HTTP_POST_VARS&#1111;"Name"];
  &#125;    
  else&#123;
    print("missing file name");
    exit;
  &#125;  
  if(isset($HTTP_POST_VARS&#1111;"Country"]))&#123;  
    $Country = $HTTP_POST_VARS&#1111;"Country"];
  &#125;  
  else&#123;
    print("wrong country name");
    exit;

  &#125;  
  if(isset($HTTP_POST_VARS&#1111;"Email"]))&#123;  
    $Email = $HTTP_POST_VARS&#1111;"Email"];   
  &#125;  
else&#123;
    print("wrong Email-address");
    exit;
  &#125;  
  if(isset($HTTP_POST_VARS&#1111;"Phone"]))&#123;  
    $Phone = $HTTP_POST_VARS&#1111;"Phone"];
  &#125;  
  else&#123;
    print("wrong phone number");
    exit;
  &#125;  

$mailto = "sujata@<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>.com";
$subject = "USDCHF pdf file download";
$header = $header."From: sujata@<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>.com\n";

$body =       "Information\n";
$body = $body."-----------\n";
$body = $body."Name   : ".$Name."\n";
$body = $body."Country: ".$Country."\n";
$body = $body."Email  : ".$Email."\n";
$body = $body."Phone  : ".$Phone."\n";

if(mail($mailto,$subject,$body,$header)) &#123;
  echo "Mail is sent!";
&#125;
else &#123;
  echo "Mail could not be sent!";
exit;
&#125;

print "<br><br>";
print("click here for start <a href="down2.php?file=usdjpy.pdf">download</a>");


$fp = fopen ("/home/web/k/<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>.com/htdocs/datfile/chfdownload.txt", "a+");
fputs ($fp, "^^$Name^^, ^^$Country^^, ^^$Email^^, ^^$Phone^^\n");
fclose($fp);


?>
one thing i want to mention that i put "a+" file access permission because i want to read and write the file any every time it should write at the end of file so that i can append new information at the below of old informations. is that write? if not then please let me know, how can be it possible? because i want exaclty these:
1) open a txt or dat file
2) store the new value at end of the file. (i don't want to delete old values)
3) download this txt or dat file so that i can get small database of user informations.

these all i need please let me if it possible or not.

and please have look at this link: http://www.<span style='color:blue' title='I&#39;m naughty, are you naughty?'>smurf</span>.com/php/pdf.html , i hope u can figure out the error.

sujata.

Posted: Tue Sep 10, 2002 1:32 am
by Takuma
What do you mean by permission problem is it because chfdownload.txt is not CHMOD to 777?

Posted: Tue Sep 10, 2002 2:49 am
by sujata ghosh
thanks Takuma!

yes the problem was due to CHMOD, it has solves and what ever i was looking for i got and it all set and done. :D

thanks once again all of you who helped me.