you guys have helped out alot! But for some reason i still get the same error as before which is it wont register the username. It wont even find the username and password. Do you have to do anything special to the form that passes the username & password to the script. I dont think it's passing the data. This is everything I have, I hope someone can help me out.. Thanks for all the help guys!!
---login.php ----
<?
require_once("zevacro_fns.php");
display_head();
?>
<form name="userlogin" method="post" action="member.php">
<table width="29%" border="0" cellspacing="2" height="92">
<tr bgcolor="#CCCCCC">
<td colspan="2">Login</td>
</tr>
<tr>
<td width="31%">Username:</td>
<td width="69%">
<input type="text" name="user">
</td>
</tr>
<tr>
<td width="31%">Password:</td>
<td width="69%">
<input type="password" name="pass">
</td>
</tr>
<tr>
<td colspan="2">
<div align="center">
<input type="submit" name="Submit" value="Login">
</div>
</td>
</tr>
</table>
</form>
</body>
</html>
---end login.php----
---member.php----
<?php
require_once("zevacro_fns.php");
session_start();
// Workaround for older versions of PHP
if (!isset($POST))
$POST=$HTTP_POST_VARS;
// Get the POSTed form variables
isset($POST['user']) ? $user=$POST['user'] : $user="";
isset($POST['pass']) ? $pass=$POST['pass'] : $pass="";
if (!(empty($user)) && (empty($pass)))
// they just tried to login
{
// connect to db
$conn=db_connect();
if (!$conn)
exit();
$result = mysql_query("SELECT username, passwrd FROM user WHERE username='$user' AND passwrd=PASSWORD('$pass')");
if (!$result)
{
echo "Could not find you in the database";
exit();
}
else
{
if (mysql_num_rows($result)<=0)
{
echo "Username does not exist<br>";
// unsuccessful login
echo "You could not be logged in.<br>";
echo "You must be logged in to view this page.<br>";
echo "Please try <a href=\"login.php\">again</a>";
exit();
}
else
{
// if they are in the database register the user id
$valid_user = $user;
//session_register("valid_user");
$_SESSION['valid_user']='$valid_user';
}
}
}
check_valid_user();
display_head();
?>
---end member.php---
---zevacro_fns.php---
---include file userauth_fns.php----
<?
function check_valid_user()
// see if somebody is logged in and notify them if not
{
if (isset($_SESSION['valid_user']))
{
echo "Logged in as {$_SESSION['valid_user']}.";
echo "<br>";
}
else
{
// they are not logged in
echo "You are not logged in.<br>";
echo "To login, <a href=\"login.php\">click here</a>";
exit;
}
}
?>
--- end userauth_fns.php----
---include db_fns.php---
<?
function db_connect()
{
$result = mysql_pconnect("localhost", "", "");
if (!$result)
return false;
if (!mysql_select_db("****"))
return false;
return $result;
}
?>
----end db_fns.php---