0

I have form post job.html and a button post. I want that when someone submits this form the values save in database and then i get these values on another helper's feed.html page. Right now, my values are saving in database but i am unable to understand how to get those values in next page.

This is the part of html code for helpers feed.

<div class="col-md-10" > 
                    <div> Description:
                <input type="text" id="desc" name="budget"class="form-control">
                <div>
                <div> Category:
                     <input type="text" id="category" name="budget" class="form-control">
                </div>
                <div  > City:
                     <input type="text" id="city" name="budget" class="form-control">
                </div>
                <div > Budget
                     <input type="text" id="budget" name="budget" class="form-control">
                </div>

This is node.js file. post.js

var mysql = require('mysql');
var express = require('express');
var bodyParser = require('body-parser');
var path = require('path');
var connection = mysql.createConnection({
    host     : 'localhost',
    user     : 'root',
    password : 'sahoolat1',
    database : 'fyp_sahoolat'
});
connection.connect(function(err){
    if(err) throw err;
    console.log("connected");
});
var app = express();

app.use(bodyParser.urlencoded({extended : false}));
app.use(bodyParser.json());

app.get('/', function(request, response) {
    response.sendFile(path.join(__dirname + '/job post.html'));
});

app.post('/post',(request,response,next)=>{
    var description=request.body.description;
    var contact_number=request.body.contact_number;
    var city=request.body.city;
    var budget=request.body.budget;
    var category=request.body.optradio;                    
   var query=connection.query("insert into jobs(Jobs_id,Description,Category,City,Contact_number,Budget) values(?,?,?,?,?,?)",[null,description,category,city,contact_number,budget],function(err){
        if(err)
            console.log(err);
        else
            console.log("moving");
            
        });
        next(); 
    });

app.get('/post',(request, response) => {
    connection.query("SELECT * FROM jobs",(err, result) => {
        if(err) {
            console.log(err);    
        }
        else { 
            console.log(result); 
            res.send(result); 
        }
    });
});

app.listen(3000);

The code runs fine till the line where i am saving in database and it prints "moving" on console.

enter image description here

I want to get each field value in the respective text fiels(as shown in screenshot)

palo
  • 159
  • 2
  • 12

0 Answers0