LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-23-2015, 03:08 PM   #1
baronobeefdip
Senior Member
 
Registered: Jul 2009
Distribution: Debian Squeeze
Posts: 1,267

Rep: Reputation: 32
How do I get a <form> to post the contents of the text inputted to a text file


here is my code, and it's not submitting to a text file

index.html
Code:
<!DOCTYPE html>
<html>
<body>
<center><form action="post.php" method="get">
<input type="text" name="name"><br>
<input type="submit" value="Submit">
</form></center>


</body>
</html>
post.php
Code:
<?php $file = 'myfile.txt';file_put_contents($file, print_r($_POST, true), FILE_APPEND);?>
<meta http-equiv="refresh" content="0; url=http://google.com" />
I am not seeing what the problem is, Is it something in my html file, what is $_POST and what variable is the html file storing the input from the textbox in? I have already setup the permissions on the files in the apache server and this still isn't working.
 
Old 09-23-2015, 03:30 PM   #2
michaelk
Moderator
 
Registered: Aug 2002
Posts: 25,700

Rep: Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895Reputation: 5895
Have you checked the http error log?

Try changing the form method from get to post.

$_POST is an array of your form's input variables.
http://www.w3schools.com/php/php_superglobals.asp
 
  


Reply



Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off



Similar Threads
Thread Thread Starter Forum Replies Last Post
[SOLVED] Bash command to 'cut' text into another text file & modifying text. velgasius Programming 4 10-17-2011 04:55 AM
[SOLVED] read a text file distrubute its contents on different text files magische_vogel Programming 13 02-26-2011 06:51 PM
How to parse text file to a set text column width and output to new text file? jsstevenson Programming 12 04-23-2008 02:36 PM
cutting down contents of text file kam_kenneth Linux - Newbie 2 05-22-2004 01:16 AM
tar from contents of a text file trpn Linux - General 3 03-08-2004 01:05 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:59 AM.

Main Menu
Advertisement
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Open Source Consulting | Domain Registration