Another problem with login page

Codes here !

Moderators: macek, egami, gesf

User avatar
wmdrumaizi
New php-forum User
New php-forum User
Posts: 40
Joined: Thu Jan 23, 2003 5:15 pm
Location: Malaysia
Contact:

Another problem with login page

Postby wmdrumaizi » Wed Apr 23, 2003 1:40 am

Hi there,

I've tried several time to create my login page but I still got an error. F.Y.I I my login form is login.html and login result is login.php

Error:

Warning: Supplied argument is not a valid MySQL result resource in C:\apache\htdocs\researchers\login.php on line 132

Warning: Cannot add header information - headers already sent by (output started at C:\apache\htdocs\researchers\login.php:17) in C:\apache\htdocs\researchers\login.php on line 135

This is my code for "login.php" that I obtained from a PHP book

Code: Select all

<?php
define ('HOST', 'localhost');
define ('USER', '');
define ('PASS', '');
define ('DB', 'researchers');

//connect to the database  and get numfound

mysql_connect(HOST, USER, PASS);

mysql_select_db(DB);

$result = mysql_query("SELECT COUNT (*) AS numfound FROM maintable WHERE username='{$HTTP_POST_VARS['username']}' AND pass='{$HTTP_POST_VARS['pass']}'");

$result_ar = mysql_fetch_array($result);
if ($result_ar['numfound'] < 1)
   {
   header( 'Location: loginform.php?error=1' );
   }
else
   {
   echo "Logged in successfully";
   }

?>


My question:
i)Page that user can enter their username and password then press 'Submit' should be ".html" or ".php"?

ii)How do I add restrict to several pages that only logged in user can access for example update, upload and rate page. I want to do this to avoid user bypass the login page by typing the directory to the restricted page.
e.g.: http://www.nbbnet.gov.my/update.php
So that when they try to bypass, they will be directed to login page.

iii)Do I need to configure php.ini file, if yes, how?

Thanks in advance

User avatar
Oleg Butuzov
Last Samuray
Last Samuray
Posts: 831
Joined: Sun Jun 02, 2002 3:09 am

Postby Oleg Butuzov » Wed Apr 23, 2003 3:42 am

$result = mysql_query("SELECT COUNT(*) AS numfound FROM maintable WHERE username='$_POST[username]' AND pass='$_POST[pass]'") or die (mysql_error());

what erorr you get????

1) mo mater, file.extension - must be extension of php script
2) set him a cookie
3) if you have thi error, it means that php workable at your server...

Regards, Pejone.


Return to “mySQL & php coding”

Who is online

Users browsing this forum: No registered users and 1 guest

cron