I'm mainly "learning" so I figured I'd try the easiest way first.
I'm trying to make a 1 user login script w/out using a db. I'll progress from there.
I have a form with fields "user" & "pass" & action="check.php", method="post".
Here is the code for check.php:
<?php
$url="admin2.php";
$username=$_POST['user'];
$password=$_POST['pass'];
$file=("../../path_to/auth.txt");
if ($username != $file['user'] || $password != $file['pass']){
include ("header.php");
echo "<table border=0 cellpadding=4 cellspacing=0><tr><td><font face=verdana size=2>Invalid username/password!</font></td></tr></table>";
include ("footer.php");
}
else {
header("Location: $url");
}
?>
The content of auth.txt:
user=myusername
pass=mypassword
When I enter the correct user/pass, the script excecutes the IF part.
Is the IF statement improperly coded or do I need to use fopen?
I don't know much about fopen, but noticed it mentioned in other tutorials.
Also, should I type in the actual file path for $file? ( c:\path_to\auth.txt )
I'll be testing it on my personal server(Windows / Xitami).
Thanks 🙂