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
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
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.