want store value into a data file from a Form

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
sujata ghosh
Forum Newbie
Posts: 4
Joined: Mon Sep 09, 2002 6:53 am
Location: India - Kolkata

want store value into a data file from a Form

Post 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.
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

http://www.php.net

research the following commands:

fopen()
fwrite()
fclose()
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

You could use "fput()"
User avatar
m3mn0n
PHP Evangelist
Posts: 3548
Joined: Tue Aug 13, 2002 3:35 pm
Location: Calgary, Canada

Post by m3mn0n »

yea that too :wink:
User avatar
mikeq
Forum Regular
Posts: 512
Joined: Fri May 03, 2002 3:33 am
Location: Edinburgh, Scotland

Post by mikeq »

it is fputs() and it is just an alias for fwrite()
sujata ghosh
Forum Newbie
Posts: 4
Joined: Mon Sep 09, 2002 6:53 am
Location: India - Kolkata

Post 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.
Last edited by sujata ghosh on Tue Sep 10, 2002 1:38 am, edited 1 time in total.
User avatar
Takuma
Forum Regular
Posts: 931
Joined: Sun Aug 04, 2002 10:24 am
Location: UK
Contact:

Post by Takuma »

What do you mean by permission problem is it because chfdownload.txt is not CHMOD to 777?
sujata ghosh
Forum Newbie
Posts: 4
Joined: Mon Sep 09, 2002 6:53 am
Location: India - Kolkata

Post 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.
Post Reply