我想用PHP插入到从网页上的MySQL数据库,但试图使用变量,当它不工作(它工作得很好,如果我使用something
同时使用$something
不)插入不与PHP变量的工作
下面是代码:
mysqli_query($con,"INSERT INTO Atendido (idPaciente,idDoctor,fecha,costo,tipoAtencion) values ('".$_GET['iddoctor']."', '".$_GET['idpacient']."', '".$_GET['date']."', '".$_GET['amount']."', '".$_GET['description']."')");
和数据来自一个其它页面与这种形式:
<form action="thanks/index.php" method="get">
<span class="largetext">ID. doctor</span><br/>
<input type="password" name="iddoctor"><br/>
<span class="largetext">ID. patient</span><br/>
<input type="password" name="idpatient"><br/>
<span class="largetext">Date</span><br/>
<input type="date" name="date"><br/>
<span class="largetext">Amount</span><br/>
<input type="number" name="amount"><br/>
<span class="largetext">Description</span><br/>
<input type="text" name="description"><br/><br/>
<input type="submit" value="Accept" style="background-color:#FF5F00; color:#FFFFFF; opacity: 0.77;">
</form>
谢谢!给所有注意到SQL injection问题的人,我也会看看这个。
我现在的作品,这里是更正后的代码:
mysqli_query($con,"INSERT INTO Atendido (idPaciente,idDoctor,fecha,costo,tipoAtencion) VALUES ('".$_GET['idpatient']."', '".$_GET['iddoctor']."','".$_GET['date']."', '".$_GET['amount']."', '".$_GET['description']."')");
圣SQL注入蝙蝠侠! –
我等待第一个评论:你是SQL注入漏洞 – aldanux
arturojain你是如何破解stackoverflow比成为aldanux :) – ismail