
Originally Posted by
josephtaylor1995
Hi, I'm a noob at php and other coding stuff so i need a little help.
What I am trying to achieve is: a textarea with a submit button, and when you click the submit button it edits/overwrites a file in my server.
If you need more info, please contact me, thanks,
Joseph
maybe this is useful
Code:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
<head>
<style type="text/css">
textarea {
font-size:11px;
font-family:"Courier New", Courier, mono;
}
</style>
</head>
<body>
<?php
if(isset($_POST['submit'])) {
$content = $_POST['contents'];
$file = fopen("script.txt", "w");
fwrite($file, $content);
fclose($file);
}
?>
<h1>Alter TEXT File</h1>
<form name="edit" method="post">
<textarea name="contents" cols="80" rows="23">
<?php
$file = "script.txt";
$open = fopen($file, "r");
$size = filesize($file);
$count = fread($open, $size);
echo($count);
?>
</textarea><br />
<input type="submit" name="submit" value="Submit">
</form>
</body>
</html>
Bookmarks