Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

247
Views
How can I take the input from a nodjs server and put it in a MySql database

So I have the api route here where we can add an user to my server

@app.route('/api/adduser', methods = ['POST']) # This is a post method because the user needs to be able to add info
def adding_stuff():
    request_data = request.get_json() # Gets the info from the table and converts to JSON format
    new_fname = request_data['firstname']
    new_lname = request_data['lastname']
    conn = create_connection("", "", "", "")
    sql = "INSERT INTO restaurantusers (firstname, lastname) VALUES ('%s', '%s');" % (new_fname, new_lname) # This sql statement will then be uploaded to the databse to add a new record
    execute_query(conn, sql) # This will execute the query
    return 'Post worked'

Then I have a NodeJs server running with the api that is selected when the form is filled out

app.post('/add_people', function(req, res){
    axios.get('http://127.0.0.1:5000/api/adduser')
    .then((response)=>{
        var restlist = response.data.results;
        console.log(restlist);
// Now we will execute the results in the page named thanks
    });
});

Lastly the form looks like this

        <form action="/add_user" method="post">
            <input type = "text" firstname = "firstname">
            <input type="submit" class="btn btn-primary">
        <h1>Lets add our last name </h1>
        <form action="/add_user" method="post">
            <input type = "text" lastname = "lastname">
            <input type="submit" class="btn btn-primary">
        </form>

What is missing or what can I add so that the user is actually added to the server?

about 4 years ago · Juan Pablo Isaza
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!