Reply to Re: Problems with login form

Your name:

Reply:


Posted by Richard Schneidt on 01/05/07 09:07

Nakkie schrieb:
> "Ric" <antispam@randometry.com> wrote in message
> news:endi5o$4dq$1@online.de...
>> Nakkie schrieb:
>>> Hi
>>>
>>> Has anyone experienced this problem before?
>> No
>>> I created a simple login page using an HTML form.
>>> PHP check the username and password against a .txt file.
>>> The authentication part is doing what it's supposed to do with both valid
>>> and invalid details.
>>> The problem comes in when I leave both fields blank and click the login
>>> button - it authenticates...... and take me to the restircetd area....
>>> I have created a password for a blank username as well as a space, but it
>>> stil does the same.
>>> Any idea how to fix this?
>>>
>>>
>> Show us some code, login form + validation code + your text file.
>> I'm not sure how you do this right not.
>>
>> --Ric
>
> Below follows the code. I got it sorted using lines 3 - 8 thanx

What do you expect from that code?

check_pass is never called so whatever you do you don't check any
password. The code below doesn't have all the info or your code is not
complete.

>
> <?
> $password_file = "/pass.txt";
> $username = $_POST['login'];
> $password = $_POST['password'];
> if($_POST['checkpass']) {

You need to make sure these params have been submitted otherwise you
will get warnings:

e.g. isset($_POST['checkpass'])
> if(empty($username) OR empty($password)) {
> echo "Username and Password is required.<br />Use your browser Back
> button to try again";
> exit;
> } else {
> }
> }
>
>
where do you call this function?

> function check_pass($login, $password) {
> global $password_file;
> if(!$fh = fopen($password_file, "r")) {die("<P>Could Not Open Password
> File - Contact the Webmaster");}
> $match = 0;
> $password = md5($password);
> while(!feof($fh)) {
> $line = fgets($fh, 4096);
> $user_pass = explode(":", $line);
> if($user_pass[0] == $login) {
> if(rtrim($user_pass[1]) == $password) {
> $match = 1;
> break;
> }
> }
> }
> if($match) {
> return 1;
> }
> else {
> return 0;
> }
> fclose($fh);
> }
>
> function print_login_form($login) {

where is this function called?

>
> ?>
>
>

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация