Thread: Small problem
View Single Post
Old 03-13-2006, 07:33 PM   #1 (permalink)
Crono254
Registered User
 
Join Date: Mar 2006
Posts: 1
Crono254 is on a distinguished road
Small problem

Hello. I have followed the guide on here:
http://php.codenewbie.com/articles/p...ns-Page_1.html
and i've done everything according to it.
Well everything is working succesfully but when i go onto my site with this script, it has some errors on the top that say:

Quote:
Notice: Undefined index: username in c:\program files\easyphp1-7\www\inc\auth.php on line 16

Notice: Undefined index: password in c:\program files\easyphp1-7\www\inc\auth.php on line 16
this happens when im not logged in. my auth.php looks like this:
PHP Code:
<?
// Login & Session example by sde
// auth.php

// start session
session_start(); 

// convert username and password from _POST or _SESSION
if($_POST){
  
$_SESSION['username']=$_POST["username"];
  
$_SESSION['password']=$_POST["password"];  
}

// query for a user/pass match
$result=mysql_query("select * from users 
  where username='" 
$_SESSION['username'] . "' and password='" $_SESSION['password'] . "'");

// retrieve number of rows resulted
$num=mysql_num_rows($result); 

// print login form and exit if failed.
if($num 1){
  echo 
"You are not authenticated.  Please login.<br><br>
  
  <form method=POST action=index.php>
  username: <input type=text name=\"username\">
  password: <input type=password name=\"password\">
  <input type=submit>
  </form>"
;
  
  exit;
}
?>
Is there any problem why it would say that? I am really new to PHP and mySql scripting, so some help would be appreciated. thanks.
Crono254 is offline   Reply With Quote