Ajay Yadav Assignment 12
Ajay Yadav Assignment 12
WEB TECHNOLOGY
1. HTML (index.html)
This file creates the form.
2. CSS (styles.css)
Save this in the same directory as index.html.
body {
font-family: Arial, sans-serif;
background-color: #f4f4f4;
text-align: center;
padding: 20px;
}
.container {
background: white;
padding: 20px;
max-width: 400px;
margin: auto;
box-shadow: 0px 0px 10px rgba(0, 0, 0, 0.1);
}
input, textarea {
width: 100%;
padding: 10px;
margin: 10px 0;
border: 1px solid #ddd;
}
button {
background: blue;
color: white;
padding: 10px;
border: none;
cursor: pointer;
}
3. JavaScript (script.js)
Handles form validation before submitting.
document.getElementById("contactForm").addEventListe
ner("submit", function(event) {
let name = document.getElementById("name").value;
let email = document.getElementById("email").value;
let message =
document.getElementById("message").value;
// Create connection
$conn = new mysqli($servername, $username,
$password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
$conn->close();
?>
ajay yadav
1. Place all files inside htdocs/form_project/ in the
XAMPP folder.
2. Open http://localhost/form_project/index.html in
your browser.
3. Fill the form and submit—data will be saved in the
database.