how can i insert data into mysql table if my table look like this:
masina(Serie, ProducatorM, ModelM, ProprietarM, An_fabricatie, Combustibil, Culoare, Culoare, Dotari, Poza)
my form look like this: Producator, Model, An_fabricatie, Combustibil, Culoare, Dotari
Serie - int, autoincrement, pk, can be null
ProducatorM - string, fk = Producator
ModelM - string, fk = Model
ProprietarM - string, fk = ??? (how to make this to automate take my Nick when i'm login)
An_fabricatie - string = An_fabricatie
Combustibil - string = Combustibil
Culoare - string = Culoare
Dotari - string = Dotari
Poza - can be null
my problem appear when i try to insert data into masina, because i'm logged in and i dont know how to set ProprietarM to get automate my nick(login nick) and put it in table..can anybody help me?
here's code from project, eclipse ee, jsp
form to complete - this is in admin.jsp
<td> <h2>Adauga masina</h2> </td> </tr> <tr> <td> <form id="filter" method="post"> <table width="438" border="0" cellspacing="0" cellpadding="0"> <tr> </tr> <tr> <td>Producator</td> <td style="height: 40px"><input type="text" name="DenumireP" /> </td> </tr> <tr> <td>Model</td> <td style="height: 40px"><input type="text" name="Denumire" /></td> </tr> <tr> <td>An fabricatie</td> <td style="height: 40px"> <input type="text" name="An_fabricatie" /></td> </tr> <tr> <td>Combustibil</td> <td style="height: 40px"><input type="text" name="Combustibil" /></td> </tr> <tr> <td>Culoare</td> td style="height: 40px"><input type="text" name="Culoare" /></td> </tr> <tr> <td>Dotari</td> <td style="height: 40px"><textarea name="Dotari" cols="40" rows="7"></textarea></td> </tr> <tr> <td>Adauga</td> <td style="height: 40px"><input type="submit" value="Adauga" name="save" /></td> </tr> </table> </form> </td> </tr>
save to database function - this is in Masini.java
public boolean save (String p, String m, String pp, String a, String c, String cul, String d) { String q = "INSERT INTO masina(ProducatorM, ModelM, ProprietarM, An_fabricatie, Combustibil, Culoare, Dotari) VALUES ('" + p + "','" + m + "','" + pp + "','" + a + "','" + c + "','" + c + "','" + d + "')"; return ppauto.query(q);