First, HTML is not in my professional toolbox. I’m just trying to muddle through to make a simple form work.
I have 2 questions:
How do you stop a php script from erasing the form fields when you do the submit? I’ve searched many posts here, most regarding JS which I’m not using. I’ve tried auto-complete=”new-password” but that didn’t appear to work. I would like the form data to remain after a submit so that if it needs to be updated the user doesn’t need to re-enter everything. Here’s a sample of what I mean:
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta charset="UTF-8"></meta>
<meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
<title>create</title>
</head>
<body>
<form method="post">
<label for="sometext"></label>
<input type="sometext" id="sometext" name="sometext" />
<button name="save">Save File</button>
</form>
<?php
if(isset($_POST['save']))
{
$text = $_POST['sometext'];
$file=fopen("myfile.txt", "w");
fwrite($file, $text);
fclose($file);
}
?>
</body>
</html>
Just what is that ‘/’ at the end of an input, for example the input line in the attached code?
Thanks,
Dave