Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form action="http://192.168.56.152:8080/submit" method="post">
- <div class="form-row">
- <div class="form-group col-md-6">
- <label for="firstname">Firstname</label>
- <input type="text" name="fname" class="form-control" id="formfirstname" placeholder="First Name">
- </div>
- <div class="form-group col-md-6">
- <label for="lastname">Last Name</label>
- <input type="text" name="lname" class="form-control" id="formlastname" placeholder="Last Name">
- </div>
- </div>
- <div class="form-row">
- <div class="form-group col-md-6">
- <label for="classify">Classification</label>
- <input type="text" name="classification" class="form-control" id="formclassify" placeholder="Junior">
- </div>
- <div class="form-group col-md-4">
- <label for="age">Age</label>
- <select id="inputState" name="state" class="form-control">
- <option selected="">16</option>
- <option>17</option>
- <option>18</option>
- <option>18</option>
- <option>20</option>
- <option>21</option>
- <option>22</option>
- <option>23</option>
- </select>
- </div>
- <div class="form-group col-md-2">
- <label for="uin">UIN</label>
- <input type="number" nam="number" class="form-control" id="uin">
- </div>
- </div>
- <button type="submit" class="btn btn-primary">Submit</button>
- </form>
- var mysql = require('mysql');
- var connetion = mysql.createConnection({ //creating connetion to database
- host:"localhost",
- user: "root",
- password: "password!",
- database: "student_info"
- });
- connetion.connect(function (err) {
- if(err) throw err;
- console.log("connection made!");
- });
- module.exports = connetion;
- const express = require('express');
- const bodyParser = require("body-parser");
- const application = express();
- const database = require('./connectplus');
- application.use(bodyParser.urlencoded({extended: true}))
- application.use(bodyParser.json());
- application.post('/submit', function(req,res) {
- const firstName = req.body.fname;
- const lastName = req.body.lname;
- res.send('You sent the name "' + firstName + ' ' + lastName + '".');
- // Later you use database query like this
- // database.query('SELECT now()');
- });
Add Comment
Please, Sign In to add comment