How can I make a script that will convert the text/data in a html textfield/textarea and send it to the server, which then saves it as a .txt file for storage?
NOTE: I am hosting a website(for testing purposes) using Apache 2.2 on a Windows 7 machine. I downloaded PHP version 5.4.7, but have not yet installed on my server yet (not sure if I will need it, but also not sure how to install it).
1st problem: Saving text to server
Html page/section with title textfield, text textarea, and submit button. You would enter a title, the text/notes you need in the textfield, then press the submit button to have it store the text in the textarea, as a .txt file on the server called .txt.
2nd problem: Opening text from server
Html with list of all txt files OR textfield for entering in title, then submit button to send the title of the requested .txt file to the server, which would then load it up on the page.
Here is what I have so far: (let me know if there is something that I should change or if something just isn't correct in the index.html code I have right now.)
<!DOCTYPE HTML>
<html>
<head>
<title>Insert Title</title>
<meta http-equiv="Content-Type" content="Text/HTML; charset=UTF-8"/>
</head>
<body>
<form method="post" action="save.INSERT_FILETYPE" name="textfile" enctype="multipart/form-data">
<input type="text" name="title"><br/>
<textarea rows="20" cols="100" id="text" name="text"></textarea><br/>
<input type="submit" name="submit" value="Submit Text to Server">
</form><br/>
<hr style="width: 100%; height: 4px;"><br/>
<form method="post" action="open.INSERT_FILETYPE" name="textfile" enctype="multipart/form-data">
<input type="text" name="title"><br/>
<input type="submit" name="submit" value="Submit Txt File Request">
</form><br/>
<div>Opened text file displays here or goes on another page</div>
</body>
</html>
I plan on using a server side language/script, but ANYTHING that gets the job done is fine. I already tried looking into using some ASP/jScript/PHP, but have had some trouble implementing it into my server. (ie: getting the modules loaded and telling the server what file types to parse.)
I know this may be an extremely easy fix, but then in that case, hopefully you wouldn't mind helping me out a little :). If it turns out that this is MUCH more complicated than I expect, then feel free to let me know that, so I don't waste me time running in circles.
I appreciate any help/assistance that you can provide,
Thanks,
Jake
EDIT: Wrong Apache version.
In response to the comments/closing of this thread:
My question: "How exactly do I install the PHP module on the apache server? and is this even possible? and is this even recommended?"
^ In case I wasn't clear enough already
To Clarify: I understand the basics of PHP, I just have trouble with INSTALLING PHP on the apache server. (I have used PHP before, but never successfully on apache (so far...))
For my script I wrote something similar to this already (using fopen() and a few other commands):
<?php
fopen("notes.txt", "r");
file_put_contents("notes.txt",teststring1);
?>
I have used javascript for this task before also (although I prefer using PHP and server-side languages):
<script language="javascript">
function WriteToFile(){
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\NewFile.txt", true);
var text=document.getElementById("TextArea1").innerText;
s.WriteLine(text);
s.WriteLine('***********************');
s.Close();
}
</script>