I place the mysqli_connect.php in the folder:
C:\xampp\htdocs\mysqli_connect.php
whereas, register.php file in the folder:
C:\xampp\htdocs\Chapter3\register.php
I also place a copy of the mysqli_connect.php file in the same folder as the register.php file to check whether mysql is connected (the result is a blank page, so I think I had connected to MySQL before running the following script)
// Check if errors do not exist
if (empty($errors)) { // If everything's OK
//Include the database connection:
require('../mysqli_connect.php');
//add the user to the database
$q = "INSERT INTO users(first_name,last_name,
email, pass, registration_date) VALUES(
'$fn','$ln','$e',SHA1('$p'),NOW())";
$r = @mysqli_query($dbc, $q); //Run the query
//Report on the sucess of the registration:
if ($r) { // If it ran OK
echo '<h1>Thank you!</h1>
<p>You are now registered. In chapter 12 you
will actually be able to log in! </p></p>
<br /></p>';
} else {
echo '<h1>System Error</h1>
<p class="error">You could not be registered due to
a system error. WE apologize for any inconvenience.
</p>';
echo '<p>' . mysqli_error($dbc) . '<br/><br/>Query: ' . $q . '</p>';
} //End of if ($r) IF.
// Close the database connection and compelte the HTML template
mysqli_close($dbc);
include('includes/footer.html');
exit();
}