Hi im a bit of a newbie at this, this script should work imo, it connects to the db, then simply stores the values from the form into the php variables. I know its not a very useful script as it doesnt send the data to the database, thats ok, just wanna do things bit by bit, but this isnt working. When i run the script it shows this error message:
Notice: Undefined index: username in c:\Program Files\Apache Group\Apache2\htdocs\login.php on line 4
Notice: Undefined index: password in c:\Program Files\Apache Group\Apache2\htdocs\login.php on line 5
and then my two text boxes and submit button.
Could someone tell me whats gone wrong? the test page works fine when i type http://localhost:8080 so I know that works. I created a mysql database then copied it to the htdocs (im running apache)
Any help would be appreciated , im dont have long til my uni project has to be completed. so please help!
<?php
//Attempt to fetch the form variables
$username = $HTTP_POST_VARS['username'];
$password = $HTTP_POST_VARS['password'];
//If the username and password are valid,
//redirect the user to the search page
if (isset ($username) && isset ($password)){
// Connect to the database
$conn = mysql_connect('localhost','root','') or die("Could not connect to mysql");
mysql_select_db('login',$conn) or die("Could not connect to mysql");
//Close the connection to the database
mysql_close($conn);
}
?>
<html>
<head>
<title>Online Library - Login</title>
</head>
<body bgcolor="#ffffff" text="#000000">
<h2>Online Library - Login</h2>
<form action ="login.php" method="POST">
Username: <input name="username" type="text" /><br />
Password: <input name="password" type="password" /><br />
<input type="submit" value="Log in" />
</form>
</body>
<html>