Professional Documents
Culture Documents
Ex 6
Ex 6
Ex 6
Step 2: Select New Project and then select Express from Generators, give name of the project
and select Handlebars from the View Engine and Click on Create button.
index.hbs:
<label for="regno">Register No</label>
<input type="text" id="regno" name="regno">
</div>
<div class="input">
<label for="gender">Gender</label>
<input type="text" id="gender" name="gender">
</div>
<button type="submit">INSERT</button>
</form>
</section>
<section class="get">
<h3>Get Data</h3>
<a href="/get-data">LOAD DATA</a>
<div>
{{#each items }}
{{/each}}
</div>
</section>
<section class="update">
<h3>Update Data</h3>
<form action="/update" method="post">
<div class="input">
<label for="name">Student Name</label>
<input type="text" id="name" name="name">
</div>
<div class="input">
<label for="regno">Registration No</label>
<input type="text" id="regno" name="regno">
</div>
<div class="input">
<label for="gender">Gender</label>
<input type="text" id="gender" name="gender">
</div>
<button type="submit">UPDATE</button>
</form>
</section>
<section class="delete">
<h3>Delete Data</h3>
<form action="/delete" method="post">
style.css:
index.js:
connection.connect((err) => {
if (err) {
console.error('Error connecting to MySQL database:', err);
} else {
console.log('Connected to MySQL database');
}
});
step5: save the program and run index.js file using npm start or run button.
Insert Data:
Read Data:
Update Data:
Delete Data: