How to use an action of a form in html

0

What kind of guys do I have a problem with, I'm trying to make a server with a register and a login and I could connect the whole database perfectly but my problem is that I have a form where there are 4 fields of input text and a submit and I want to that when I touch the submit the form with the action method I send a "route" and in express I can generate a router.post and with that route I can grab the input values and save them. The issue is that that "route" that the action method generates never gives me. This is my form:

<form action="/register/add" method="post"></form>
        <p>Nombre</p>
        <input type="text" name="inputname" id="inputname" placeholder="Nombre">;                                
        <p>Apellido</p>
        <input type="text" name="inputsurname" placeholder="Apellido" id="inputsurname">
        <p>Email</p>
        <input type="text" name="inputemail" placeholder="Email" id="inputemail">
        <p>Contraseña</p>
        <input type="password" name="inputpassword" placeholder="Contraseña" id="inputpassword">
        <button type="input" id="inputbutton">¡Registrate!</button>
    </form>

And the code where I ask the "route" to the action to give an answer is this:

routes.post("/register/add", (req, res)=>{
    console.log("prueba");

}); Do I have to call the script where I have the routes.post in the html? Do I need any other dependence on express like bodyparser or some of that style? I'm using express. Excuse the ignorance, thank you very much.

    
asked by Pedro Danderfer 11.11.2018 в 01:56
source

0 answers