Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

239
Vistas
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
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda