Nodejs
Nodejs
npm init -y
2.npm install express mysql body-parser
3.create database
index.html
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Insert User Data</title>
<style>
body {
font-family: Arial, sans-serif;
margin: 50px;
}
form {
max-width: 400px;
margin: 0 auto;
}
label, input {
display: block;
margin-bottom: 10px;
}
button {
padding: 10px 20px;
background-color: #007BFF;
color: white;
border: none;
cursor: pointer;
}
</style>
</head>
<body>
<h1>Insert User Data</h1>
<form action="/adduser" method="post">
<label for="name">Name:</label>
<input type="text" id="name" name="name" required>
<label for="email">Email:</label>
<input type="email" id="email" name="email" required>
<button type="submit">Submit</button>
</form>
</body>
</html>
5. create app.js file
// Connect to MySQL
db.connect((err) => {
if (err) {
throw err;
}
console.log('MySQL Connected...');
});
6.start server
node app.js
7. port address
localhost:3000