Thanks for taking the time to look at this. This is my first attempt at doing live work. The first information is my html form, then the connection file and then the file to validate the form. I had the html and validate form in an admin folder and the connection file was at the base level. I used the ../ in my validate file at that time. I would get a connection but it kept insisting it could not find the database? It definitely is on the server.
THIS IS THE HTML FORM
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<link type="text/css" rel="stylesheet" href="jJa_styles.css" />
<title>Administrative Login</title>
</head>
<body>
<table width="634" border="0">
<tr>
<td width="295"><img src="images/LogoN.gif" alt="" width="353" height="80" /></td>
</tr>
<tr>
<td valign="top"><form id="login" method="post" action="validateLogin.php">
<p class="h2">Administrative Login </p>
<p class="body"> Username: <input name="username" type="text" size="25" maxlength="25" />
<br />
<br />
Password: <input name="password" type="password" size="25" maxlength="25" />
<br />
<br />
<input name="submit" type="submit" value="LogIn" />
</p>
</form> </td>
</tr>
</table>
</body>
</html>
THIS IS HOW I WROTE THE CONNECTION CODE . . . I would get the echo.
<?php
$DBConnect = mysqli_connect("000.000.000.00", "myName", "myPassword")//connect to database server
Or die("<p>Unable to connect to the database server.</p>"
. "<p>Error code " . mysqli_connect_errno()
. ": " . mysqli_connect_error()) . "</p>";
// echo "<p>Successfully connected to the database server.</p>";
$DBName = "myDatabase";
?>
THIS IS MY VALIDATE CODE _____THE TABLE IT WILL CONNECT TO HAS auth_ID, fName, lName, username and password as the five fields.
<?php
session_start();
//check for required fields from the form
if ((!$_POST[username]) || (!$_POST[password])) {
header("Location: adminLogIn.php");
exit;
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1" />
<title>Validate Admin Login</title>
</head>
<body>
<?php
//connect to server THIS IS WHERE IT WOULD DIE AND I GET THE UNABLE TO SELECT THE DATABASE ERROR
include("../mysqli_connect.php");
mysqli_select_db($DBConnect, $DBName)
Or die("<p>Unable to select the database.</p>" . "<p>Error code " . mysqli_errno($DBConnect) . ": " . mysqli_error($DBConnect)) . "</p>";
// echo "<p>i'm here</p>";
//create query
$TableName = "auth_users";
$SQLstring = "SELECT fName,lName FROM $TableName WHERE username='$_POST[username]' AND password=password('$_POST[password]')";
$QueryResult = mysqli_query($DBConnect, $SQLstring)
Or die("<p>Unable to execute the query.</p>" . "<p>Error code " . mysqli_errno($DBConnect) . ": " . mysqli_error($DBConnect)) . "</p>";
if (mysqli_num_rows($QueryResult) == 0)
die("<p>You must enter a registered username! Click your browser's Back button to return to the Registration form.</p>");
$Row = mysqli_fetch_row($QueryResult);//ends the script section to assign the user id number
if ($authPassword != $Row[4])
die("<p>You did not enter a valid password! Click your browser's Back button to return to the Registration form.</p>");
else
$_SESSION['authID'] = $Row[0];
?>
</body>
</html>
MOD EDIT: PHP/HTML bbcode tags added. Please use these in the future when posting code!