I thought that I should use JSON for ID/pass storing format once, but I reserched about it, then I finally found that JSON is too difiicult to me, so now I am considering to use CSV.
The CSV file would be like this. File name is id.csv.
aaa_id,aaa_pass
bbb_id,bbb_pass
ccc_id,ccc_pass
Left colum is id, and right colum is password and each infos are separated by commas. Login form is login.php. This is my sample for login.php.
<form method="post" action="login-process.php">
id <input type="text" name="id" size="20"><br>
pass <input type="text" name="pass" size="20"><br>
<input type="submit" value="login">
</form>
And now I need to write login-process.php
<?php
error_reporting(0);
$handle = fopen("id.csv", "r");
while (($data = fgetcsv($handle)) !== FALSE) {
print $data['0'];
print "=>";
print $data['1'];
print "<br>";
}
?>
When I excute this script, it shows as:
aaa_id=>aaa_pass
bbb_id=>bbb_pass
ccc_id=>ccc_pass
I feel I am closing to final goal, but I need to write authenticate code.
How do I improvement of this code?