Skip to content

Instantly share code, notes, and snippets.

@ha-yi
Created September 27, 2013 15:43
Show Gist options
  • Save ha-yi/6730675 to your computer and use it in GitHub Desktop.
Save ha-yi/6730675 to your computer and use it in GitHub Desktop.
<?php
if (isset($_POST['submit'])) {
$Fname = $_POST['fname'];
$Lname = $_POST['lname'];
$fp = fopen("input.txt","a");// Open data.txt for writing
if(!$fp) {
echo 'Error, the file could not be opened or there was an error creating it.';
exit;
}
if(@fwrite($fp, $Fname.'|'.$Lname."\n")){
echo 'Record Added';
}else{
echo 'Failed';
}
fclose($fp);
}
?>
<html>
<body>
<form name="input" method="post" action="<?php echo $_SERVER['SCRIPT_NAME']?>">
<p><label for="firstname">First Name: </label>
<input type="text" name="fname" id="fname" /></p>
<p><label for="firstname">Last Name: </label>
<input type="text" name="lname" id="lname" />
<p><input type="reset" name="reset" value="reset" />
<input type="submit" name="submit" value="submit" /></p>
</form>
</body>
</html>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment