Jump to content


Photo

Need help


  • Please log in to reply
7 replies to this topic

#1 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 03:37 PM

I'am trying to creat a form, I want the user to type some information and then this information to be saved in the text file. here is the code, but of course it doesn't work:(

<?php
$file = "text.txt"; //file where the information will be stored
$input_file = file($file); //opens the file and writes an array
$file_write = fopen($file, "w+"); // open file with write
$name = $_POST["name"];
fputs($file_write, print($name), "$input_file[0]"); // input the info from form
fclose($file_write);
echo "your info is saved";
?>
I don't need your script, I'll try to write it myself

#2 trq

trq
  • Staff Alumni
  • Advanced Member
  • 31,041 posts

Posted 20 July 2006 - 03:43 PM

doesn't work

Doesn't help. Take a read of the link in my signiture.

#3 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 20 July 2006 - 03:43 PM

Remove print from this line:
fputs($file_write, print($name), "$input_file[0]"); // input the info from form

so its just:
fputs($file_write, $name, "$input_file[0]"); // input the info from form

#4 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 03:48 PM

thanks, but It doesn't write anything in the text file....
I don't need your script, I'll try to write it myself

#5 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 20 July 2006 - 03:58 PM

ok, I'll try some tutorials, if I can find, thanks guys
I don't need your script, I'll try to write it myself

#6 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 21 July 2006 - 12:50 PM

hey guys, please help, I really need this, I've several tutorials about this, but it's not clear enough for me....
well, my problem is that when I input the text in the "name" field, it doesn't save the info in the text file. hope u can help, thanks.

here is the code of the form:
<form action="form.php" method="post" name="input" >
Name:<input type="text" name="name" />
<input type="submit" value="save" />
</form>


and here is the php code:

<?php
$file = "text.txt"; //file where the information will be stored
$input_file = file($file); //opens the file and writes an array
$file_write = fopen($file, "w+"); // open file with write
$name = $_POST["name"];
fputs($file_write, $name, "$input_file[0]"); // input the info from form
fclose($file_write);
echo "your info is saved";
?>

I don't need your script, I'll try to write it myself

#7 wildteen88

wildteen88
  • Staff Alumni
  • Advanced Member
  • 10,482 posts
  • LocationUK, Bournemouth

Posted 21 July 2006 - 02:43 PM

Change:
fputs($file_write, $name, "$input_file[0]"); // input the info from form
to:
fputs($file_write, $name); // input the info from form


#8 Gruzin

Gruzin
  • Members
  • PipPipPip
  • Advanced Member
  • 448 posts
  • LocationGeorgia

Posted 21 July 2006 - 03:14 PM

Thanks for help it works! 8)
I don't need your script, I'll try to write it myself




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users