Connecting a database to a web application is a fundamental process for creating dynamic and interactive websites. Databases store and manage the data your application relies on, ensuring smooth user experiences and efficient functionality. This guide provides a detailed, step-by-step explanation of how to connect a database to your web application.
Step 1: Understand Your Project Requirements.
- install xamp server.
- chose a text editor like a notepad, or sublime text editor.
- now to xamp folder and open htdos folder
- make basantlogon folder.
In basantlog folder make this files
Code for project
<?php
$servername =”localhost”;
$username =”root”;
$password =””;
$dbname =”learn”;
$conn = mysqli_connect($servername, $username, $password, $dbname);
if ($conn) {
// echo “Connection successful”;
} else {
echo “Connection failed: ” . mysqli_connect_error();
}
?>
/* Google Font Import */
@import url(‘https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;600&display=swap’);
* {
margin: 0;
padding: 0;
box-sizing: border-box;
font-family: ‘Poppins’, sans-serif;
}
/* Body Styling */
body {
display: flex;
justify-content: center;
align-items: center;
height: 100vh;
background: linear-gradient(135deg, #74b9ff, #6c5ce7);
padding: 20px;
}
.container{
width: 100%;
max-width: 700px;
padding: 20px;
box-shadow:0px 5px 15px rgba(0, 0, 0, 0.2); ;
background: white;
border-radius: 20px;
border: 2px solid black;
margin: 20px auto;
}
.title{
font-size: 22px;
font-weight: 600;
color: darkorange;
text-align: center;
margin-bottom: 20PX;
}
/* Form Styling */
.form{
display: flex;
flex-direction: column;
gap: 12px;
}
.input_field {
display: flex;
flex-direction: column;
text-align: left;
}
.input_field label {
font-size: 20px;
font-weight: 500;
color: #333;
margin-bottom: 5px;
}
.input{
width: 100%;
padding: 20px;
font-size: 25px;
border: 1px solid #ccc;
border-radius: 5px;
transition: 0.3s;
}
.input_field p{
text-align: center;
font-size: 20px;
font-weight: 500;
color: #333;
margin-bottom: 5px;
}
.input: focus{
border-color: #6c5ce7;
outline: none;
box-shadow: 0px 0px 5px rgba(108, 92, 231, 0.5);
}
select {
width: 100%; /* Ensures full width */
padding: 5px;
border-radius: 5px;
font-size: 14px;
border: 1px solid #ccc;
}
.check {
display: flex;
align-items: center;
gap: 10px;
width: 25px;
height: 25px;
margin-top: 10px;
border-radius: 10px solid;
}
.btn{
background:#6c5ce7;
color: white;
border: none;
padding: 10px;
font-size: 16px;
border-radius: 5px;
cursor: pointer;
transition: 0.3s;
font-weight: 500;
margin-top: 10px;
}
.btn:hover {
background: #4834d4;
}
/* Responsive Design */
@media (max-width: 450px) {
.container {
max-width: 100%;
}
}
Register.php out put

Inserted data

Table of Contents
Toggle