so, i have three tables, user, modules, and an intermediate table user_module, to do an inner join between user and module i have to access thorough user_module
"SELECT user.uName, module.moduleName FROM user_module INNER JOIN user ON user.userID = user_module.userID_FK INNER JOIN module ON module.moduleID = user_module.moduleID_FK;",
i have a form that allows me to insert the information for the user, and i would like to chose which module a user take. until now i have been putting the information manually with phpmyadmin for the user_module table, the rest f the information for user comes from the node.js code
const parsed = bodyParser.urlencoded({ extended: false });
app.post("/", parsed, (req, res, next) => {
console.log(req.body);
connection.query(
"INSERT INTO user(name,surname,gender,dateOfBirth,email,userName,password) values('" +
req.body.name1 +
"','" +
req.body.surname1 +
"','" +
req.body.gender +
"','" +
req.body.birtdate +
"','" +
req.body.email1 +
"','" +
req.body.username1 +
"','" +
req.body.password1 +
"');",
(err, row, field) => {
if (!err) {
res.redirect("/");
} else {
console.log(err);
}
}
);
});
But how i can take the information from the form, and put the 2 id's in the intermediate table?
<form action="/" method="post">
<p>Name:</p>
<input type="text" name="name1" /><br />
<p>Surname:</p>
<input type="text" name="surname1" /><br />
<p>Gender:</p>
<select name="gender">
<option value="m">Male</option>
<option value="f">female</option> </select
><br />
<p>course:</p>
<select name="module">
<option value="1">Programming</option>
<option value="2">webApp</option> </select
><br />
<p>Date of Birth:</p>
<input type="date" name="birtdate" placeholder="select Birth date" />
<p>Email:</p>
<input type="email" name="email1" />
<p>Username:</p>
<input type="text" name="username1" />
<p>Password:</p>
<input type="password" name="password1" /> <br />
<input type="submit" value="submit" />
</form>
node.jsbut i do know EcmaScript (Javascript) but i am pretty sure that code is prone to (blind) SQL injections..node.jsseams to be supporting mine statement -> Escaping query values