我正在尝试创建与db连接的表单。我写了插入语句,但它说我有一个错误,我找不到它。我的目的是填写表单,值将保存在db中的3个不同的表中。这是我的代码的一部分。 这是插入语句:
$insert = "INSERT INTO Gjinekologjia VALUES(
'" .$_POST['Nr_kartele'] . "',
'" .$_POST['Emri'] . "',
'" .$_POST['Mbiemri'] . "',
'" .$_POST['Mosha'] . "',
'" .$_POST['Pariteti'] . "',
'" .$_POST['E_siguruar'] . "',
'" .$_POST['Adresa'] . "',
'" .$_POST['Dt_e_shtrimit'] . "',
'" .$_POST['Dite_qendrimi'] . "',
'" .$_POST['Diagnoza'] . "',
'" .$_POST['Nomenkletura'] . "',
'" .$_POST['Intervent'] . "',
'" .$_POST['Intervent_urgjent'] . "',
'" .$_POST['Hemotransfuzion'] . "',
'" .$_POST['Material_per_biopsi'] . "',
'" .$_POST['Histerectomi'] . "',
'" .$_POST['Plastike'] . "',
'" .$_POST['Adnexectomi'] . "',
'" .$_POST['Abrazio'] . "',
'" .$_POST['HSG'] . "',
'" .$_POST['LEEP'] . "',
'" .$_POST['PAP'] . "',
'" .$_POST['Colposcopi'] . "')
UNION
INSERT INTO abortet values ('" .$_POST['Nderpreje_e_vullnetshme'] . "',
'" .$_POST['Abort_spontan'] . "',
'" .$_POST['Missed_abortion'] . "')
UNION
INSERT INTO komplikacion_i_interventit values ( '" .$_POST['Infeksion'] . "',
'" .$_POST['Hemoragji'] . "',
'" .$_POST['Ileus'] . "')
RIGHT JOIN abortet
ON Gjinekologjia.ID_Abortet=abortet.ID_Abortet,
LEFT JOIN komplikacion_i_interventit
ON Gjinekologjia.ID_Komplikacion_i_interventit=komplikacion_i_interventit.ID_Komplikacion_i_interventit;";
这是我的表格:
<form action="Gjinekologjia.php" method="post">
<div class="form-group">
<label for="text">Nr i karteles:</label>
<input type="text" class="form-control" id="Nr_kartele" name="Nr_kartele" placeholder="Nr i karteles i pacientit">
</div>
<div class="form-group">
<label for="text">Emri:</label>
<input type="text" class="form-control" id="Emri" name="Emri" placeholder="Shkruani emrin e pacientit">
</div>
<div class="form-group">
<label for="text">Mbiemri:</label>
<input type="text" class="form-control" id="Mbiemri" name="Mbiemri" placeholder="Shkruani mbiemrin e pacientit">
</div>
<div class="form-group">
<label for="text">Mosha:</label>
<input type="text" class="form-control" id="Mosha" name="Mosha" placeholder="Shkruani moshen e pacientit">
</div>
<div class="form-group">
<label for="text">Pariteti:</label>
<div class="radio">
<label><input type="radio" name="Pariteti" value="1">Primipare</label>
</div>
<div class="radio">
<label><input type="radio" name="Pariteti" value="0">Pluripare</label>
</div>
</div>
<div class="form-group">
<label for="text">E siguruar:</label>
<div class="radio">
<label><input type="radio" name="E_siguruar" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="E_siguruar" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Adresa:</label>
<div class="radio">
<label><input type="radio" name="Adresa" value="1">Qytet</label>
</div>
<div class="radio">
<label><input type="radio" name="Adresa" value="0">Fshat</label>
</div>
</div>
<div class="form-group">
<label for="text">Data e shtrimit:</label>
<input type="text" class="form-control" id="Dt_e_shtrimit" name="Dt_e_shtrimit" placeholder="Shkruani daten e shtrimit te pacientit">
</div>
<div class="form-group">
<label for="text">Dite qendrimi:</label>
<input type="text" class="form-control" id="Dite_qendrimi" name="Dite_qendrimi" placeholder="Shkruani ditet e qendrimit te pacientit">
</div>
<div class="form-group">
<label for="text">Diagnoza:</label>
<input type="text" class="form-control" id="Diagnoza" name="Diagnoza" placeholder="Shkruani diagnozen e pacientit">
</div>
<div class="form-group">
<label for="text">Nomenkletura:</label>
<input type="text" class="form-control" id="Nomenkletura" name="Nomenkletura" placeholder="Shkruani Nomenkleturen e pacientit">
</div>
<div class="form-group">
<label for="text">Intervent:</label>
<div class="radio">
<label><input type="radio" name="Intervent" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Intervent" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Intervent urgjent:</label>
<div class="radio">
<label><input type="radio" name="Intervent_urgjent" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Intervent_urgjent" value= "0">Jo</label>
</div>
</div>
<h3>Komplikacion i interventit</h3>
<div class="form-group">
<label for="text">Infeksion:</label>
<div class="radio">
<label><input type="radio" name="Infeksion" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Infeksion" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Hemoragji:</label>
<div class="radio">
<label><input type="radio" name="Hemoragji" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Hemoragji" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Ileus:</label>
<div class="radio">
<label><input type="radio" name="Ileus" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Ileus" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Hemotransfuzion:</label>
<div class="radio">
<label><input type="radio" name="Hemotransfuzion" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Hemotransfuzion" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Material per biopsi:</label>
<div class="radio">
<label><input type="radio" name="Material_per_biopsi" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Material_per_biopsi" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Histerectomi:</label>
<div class="radio">
<label><input type="radio" name="Histerectomi" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Histerectomi" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Plastike:</label>
<div class="radio">
<label><input type="radio" name="Plastike" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Plastike" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Adnexectomi:</label>
<div class="radio">
<label><input type="radio" name="Adnexectomi" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Adnexectomi" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Abrazio:</label>
<div class="radio">
<label><input type="radio" name="Abrazio" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Abrazio" value= "0">Jo</label>
</div>
</div>
<h3>Abortet</h3>
<div class="form-group">
<label for="text">Nderpreje e vullnetshme:</label>
<div class="radio">
<label><input type="radio" name="Nderpreje_e_vullnetshme" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Nderpreje_e_vullnetshme" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Abort spontan:</label>
<div class="radio">
<label><input type="radio" name="Abort_spontan" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Abort_spontan" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">Missed abortion:</label>
<div class="radio">
<label><input type="radio" name="Missed_abortion" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="Missed_abortion" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">HSG:</label>
<div class="radio">
<label><input type="radio" name="HSG" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="HSG" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">LEEP:</label>
<div class="radio">
<label><input type="radio" name="LEEP" value= "1">Po</label>
</div>
<div class="radio">
<label><input type="radio" name="LEEP" value= "0">Jo</label>
</div>
</div>
<div class="form-group">
<label for="text">PAP Test:</label>
<div class="radio">
<label><input type="radio" name="PAP" value="Normale">Normale</label>
</div>
<div class="radio">
<label><input type="radio" name="PAP" value="Jo_normale">Jo normale</label>
</div>
<div class="radio">
<label><input type="radio" name="PAP" value="Jo">Jo</label>
</div>
<div class="form-group">
<label for="text">Colposcopi</label>
<div class="radio">
<label><input type="radio" name="Colposcopi" value="Pozitive">Pozitive</label>
</div>
<div class="radio">
<label><input type="radio" name="Colposcopi" value="Negative">Negative</label>
</div>
<div class="radio">
<label><input type="radio" name="Colposcopi" value="Jo">Jo</label>
</div>
<button type="submit" class="btn btn-default" name="ruaj" >Ruaj</button>
</form>
请帮帮我......
答案 0 :(得分:0)
首先重要的事情:您创建的是SQL注入。 https://en.wikipedia.org/wiki/SQL_injection
请使用预先准备好的陈述:https://en.wikipedia.org/wiki/Prepared_statement
你没有指定使用的sql方言。没有这些信息,就不可能100%正确地回答这个问题。但我知道没有方言,插入语句中的联合是可能的。