Skip to content

Instantly share code, notes, and snippets.

@weeklyd3
Last active July 27, 2021 16:50
Show Gist options
  • Save weeklyd3/15569169b147916fa1c0eef9ec249f68 to your computer and use it in GitHub Desktop.
Save weeklyd3/15569169b147916fa1c0eef9ec249f68 to your computer and use it in GitHub Desktop.
StackOverflow question 68537359
<!-- Here is the HTML form. -->
<form action="process.php" method="post">
<input type="text" placeholder="Your Value" name="text" />
<input type="submit" value="Send" />
</form>
<?php
// Since you have PHP on your web
// server, save this as
// 'process.php' on your server.
if (isset($_POST['text']) {
$text = $_POST['text'];
$handle = fopen('yourfile.txt', 'a+');
$status = fwrite($handle, $text."\n");
if ($status) {
echo 'Write completed';
exit(0);
} else {
echo 'Oops! We couldn\'t write the data!';
exit(1);
}
} else {
echo 'Enter your text <a href="form.html">here</a>.';
exit(1);
?>
// Values are added here.
value1
value2
value3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment