Sure.
Here is the connect.php file:
<?php DEFINE ('DB_USER','root'); DEFINE ('DB_PASSWORD','2f8ks32d'); DEFINE ('DB_HOST','localhost'); DEFINE ('DB_NAME','phpbook'); $dbc = mysqli_connect(DB_HOST, DB_USER, DB_PASSWORD, DB_NAME) OR die('Could not connect' . mysqli_connect_error()); mysqli_set_charset($dbc, 'utf8'); ?>
And here is part of the register.php page:
if(empty($errors)){ require('http://localhost/PHP/chp8/connect.php'); $q = "INSERT INTO users (user_id, first_name, last_name, email, pass, registration_date) VALUES (0,'$fn', '$ln', '$e', SHA1('$p'), NOW())"; $r = mysqli_query($dbc, $q); if($r){ echo '<h1>Thank you!</h1>'; echo '<p>You are now registered</p>'; } else{ echo '<h1>System Error</h1> <p>You could not register due to a system error.</p>'; echo '<p>' . mysqli_error($dbc) . '<br>' . 'Query:' . $q . '</p>'; } mysqli_close($dbc); } else{ echo '<h1>Error(s)</h1>'; foreach($errors as $msg){ echo '<span class="error"> -'. $msg . '</span><br>'; } }
I just noticed, if I change the URL in the require('http://localhost/PHP/chp8/connect.php');
to: require('connect.php');
It works!
I don't understand why it wouldn't work with an absolute URL...?
Thank you for the reply.