Gruzin Posted July 20, 2006 Share Posted July 20, 2006 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 formfclose($file_write);echo "your info is saved";?> Quote Link to comment https://forums.phpfreaks.com/topic/15160-need-help/ Share on other sites More sharing options...
trq Posted July 20, 2006 Share Posted July 20, 2006 [quote]doesn't work[/quote]Doesn't help. Take a read of the link in my signiture. Quote Link to comment https://forums.phpfreaks.com/topic/15160-need-help/#findComment-61077 Share on other sites More sharing options...
wildteen88 Posted July 20, 2006 Share Posted July 20, 2006 Remove print from this line:fputs($file_write, print($name), "$input_file[0]"); // input the info from formso its just:fputs($file_write, $name, "$input_file[0]"); // input the info from form Quote Link to comment https://forums.phpfreaks.com/topic/15160-need-help/#findComment-61078 Share on other sites More sharing options...
Gruzin Posted July 20, 2006 Author Share Posted July 20, 2006 thanks, but It doesn't write anything in the text file.... Quote Link to comment https://forums.phpfreaks.com/topic/15160-need-help/#findComment-61085 Share on other sites More sharing options...
Gruzin Posted July 20, 2006 Author Share Posted July 20, 2006 ok, I'll try some tutorials, if I can find, thanks guys Quote Link to comment https://forums.phpfreaks.com/topic/15160-need-help/#findComment-61092 Share on other sites More sharing options...
Gruzin Posted July 21, 2006 Author Share Posted July 21, 2006 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 formfclose($file_write);echo "your info is saved";?> Quote Link to comment https://forums.phpfreaks.com/topic/15160-need-help/#findComment-61618 Share on other sites More sharing options...
wildteen88 Posted July 21, 2006 Share Posted July 21, 2006 Change:[code]fputs($file_write, $name, "$input_file[0]"); // input the info from form[/code]to:[code]fputs($file_write, $name); // input the info from form[/code] Quote Link to comment https://forums.phpfreaks.com/topic/15160-need-help/#findComment-61658 Share on other sites More sharing options...
Gruzin Posted July 21, 2006 Author Share Posted July 21, 2006 Thanks for help it works! 8) Quote Link to comment https://forums.phpfreaks.com/topic/15160-need-help/#findComment-61674 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.