Last active
July 27, 2021 16:50
-
-
Save weeklyd3/15569169b147916fa1c0eef9ec249f68 to your computer and use it in GitHub Desktop.
StackOverflow question 68537359
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!-- 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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?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); | |
?> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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