lutherfchen Posted October 19, 2014 Share Posted October 19, 2014 Hello guys, I'm wondering if i can connect my users with text files. My text file looks like this: [data] Password = asd Email = asd@asd . . . ... [end] So I have my code like this: $username = $_GET['username']; $password = $_GET['password']; bla. bla. bla But I don't know how to do it to check if the password inputted is the same as the one in the text file. Can someone help me with this code? Link to comment Share on other sites More sharing options...
0 Haggis Veteran Posted October 19, 2014 Veteran Share Posted October 19, 2014 you would need something like this $userN = $_GET['username']; $passW = $_GET['password']; $userlist = file ('users.txt'); $checkUser =$userlist[0]; if (isset($_POST['login'])) { if ($userN == $userlist) { echo "<br> Hi $user you have been logged in. <br>"; } else { echo "<br> You have entered the wrong username or password. Please try again. <br>"; } } Link to comment Share on other sites More sharing options...
0 lutherfchen Posted October 19, 2014 Author Share Posted October 19, 2014 Hi Haggis, Thank for your reply. Why I use if($password === $checkpass) it always fail? even if i typed the correct one? I also tried this: if(!success) { echo "$password is not equal to $checkpass"; } and it shows like the same things: asd is not equal to asd WHY? Link to comment Share on other sites More sharing options...
0 kjordan2001 Posted October 27, 2014 Share Posted October 27, 2014 Hi Haggis, Thank for your reply. Why I use if($password === $checkpass) it always fail? even if i typed the correct one? I also tried this: if(!success) { echo "$password is not equal to $checkpass"; } and it shows like the same things: asd is not equal to asd WHY? There's probably whitespace. Use trim($checkpass). Link to comment Share on other sites More sharing options...
Question
lutherfchen
Hello guys, I'm wondering if i can connect my users with text files.
My text file looks like this:
[data]
Password = asd
Email = asd@asd
.
.
.
...
[end]
So I have my code like this:
$username = $_GET['username'];
$password = $_GET['password'];
bla. bla. bla
But I don't know how to do it to check if the password inputted is the same as the one in the text file.
Can someone help me with this code?
Link to comment
Share on other sites
3 answers to this question
Recommended Posts