Stop PHP from clearing a form

  Kiến thức lập trình

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" "">
    <html xmlns="">
    <meta charset="UTF-8"></meta>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"></meta>
    <form method="post">
    <label for="sometext"></label>
    <input type="sometext" id="sometext" name="sometext" />
    <button name="save">Save File</button>
            $text = $_POST['sometext'];
            $file=fopen("myfile.txt", "w");
            fwrite($file, $text);
  • What is that ‘/’ at the end of an input, for example the input line in the attached code?