Connect_db.php using one with example registration user page


I used some example php code, when a user registers, it used connect_db.php for all pages, so once registered, a login page link should load after.


$servername = "";

$username = "";

$password = "";

// Create connection

$conn = new mysqli($servername, $username, $password);

// Check connection

if ($conn->connect_error) {

die("Connection failed: " . $conn->connect_error);


echo "Connected successfully";

I used an example for connect_db from w3schools, so after that, I don’t know what should happen, I then tried the above from another php page, doesn’t do anything. I guess it wouldn’t. Since connect_db is simply a file to test the database connection and have everything connected with it.

So how would a registerd user be sent to the database, all that happens with the registration is connected successfully.


# Set page title and display header section.

$page_title = 'Register' ;

include ( 'includes/header.html' ) ;

# Check form submitted.



# Connect to the database.

require ('connect_db.php');

I don’t know if the code I use, ends up using a very specific code. Old php or something.

Please format your code by placing “~~~” before and after it.

1 Like

This topic was automatically closed 15 days after the last reply. New replies are no longer allowed.