I'm a newbie in HTML and PHP. I've created a form using HTML, and I need to retrieve the input data and save it to a text file. For this I created a .php file. But when I submit the form, the answers do not get saved. Also after submitting, the web page shows the content of the php file. I would really appreciate if someone could point out what I'm doing wrong or advise me on what I should do.
Here is my .html file :
<html>
<body>
<h1>Login</h1>
<form action="config.php">
<input type="text" name="username" >
<label for="">Username</label><br>
<input type="password" name="password">
<label for="">Password</label>
<input type="submit" value="Save">
</form>
</body>
</html>
And the .php file :
<?php
extract($_REQUEST);
$file=fopen("form-save.txt","a");
fwrite($file,"name :");
fwrite($file, $username ."\n");
fwrite($file,"Password :");
fwrite($file, $password ."\n");
fclose($file);
?>