我正在尝试使用php进行分析。我不知道怎么检查。它唯一能检查的是formno,firstname和lastname。
<?php
$FrmN = $_POST["formno"];
$FN = $_POST["firstname"];
$LN = $_POST["lastname"];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
mysql_select_db("vianney300", $con);
$sql = "INSERT INTO profile(FormNo, FirstName, LastName)
VALUES ('$FrmN', '$FN', '$LN')";
if (!mysql_query($sql,$con))
{
die('Error: ' . mysql_error());
}
echo "<br>1 record added!";
mysql_close($con);
?>
答案 0 :(得分:0)
尝试以下代码
<?php
$FrmN = $_POST["formno"];
$FrnN=$mysqli->real_escape_string($FrmN);
$FN = $_POST["firstname"];
$FN=$mysqli->real_escape_string($FN);
$LN = $_POST["lastname"];
$LN=$mysqli->real_escape_string($LN);
$con = mysqli_connect("localhost","root","");
if (!$con)
{
die('Could not connect: ' . mysqli_error());
}
mysqli_select_db("vianney300", $con);
$sql = "INSERT INTO profile(FormNo, FirstName, LastName)
VALUES ('{$FrmN}', '{$FN}', '{$LN}')"";
if (!mysqli_query($sql,$con))
{
die('Error: ' . mysqli_error());
}
echo "<br>1 record added!";
mysqli_close($con);
?>