Last active
October 23, 2017 02:09
-
-
Save ericjames/1472d6f347f236a415be4e2e85e51ffe to your computer and use it in GitHub Desktop.
PHP Save Feedback - A simple script to store some input field data into a local text file
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 | |
$date = date ("l, F jS, Y"); | |
$time = date ("h:i A"); | |
$msg = ""; | |
if ($_SERVER['REQUEST_METHOD'] == "POST") { | |
foreach ($_POST as $key => $value) { | |
$msg .= ucfirst ($key) ." : ". $value . "\n"; | |
} | |
} | |
else { | |
foreach ($_GET as $key => $value) { | |
$msg .= ucfirst ($key) ." : ". $value . "\n"; | |
} | |
} | |
$file = 'feedback.txt'; | |
$current = file_get_contents($file); | |
$current .= " -- \n"; | |
$current .= $date . ' ' . $time . "\n"; | |
$current .= $_SERVER['HTTP_USER_AGENT'] . "\n"; | |
$current .= $msg; | |
if (file_put_contents($file, $current)) { | |
echo "yay"; | |
} else { | |
echo "fail"; | |
} | |
if ($msg == "") { | |
echo "fail message did not work"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment