Jump to content

Need help


Gruzin

Recommended Posts

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";
?>
Link to comment
https://forums.phpfreaks.com/topic/15160-need-help/
Share on other sites

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";
?>
Link to comment
https://forums.phpfreaks.com/topic/15160-need-help/#findComment-61618
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.