我基本上想要制作一个HTML表单,其中用户插入两个不同的输入。 然后将这些输入与存储在MySQL表中的数据进行比较。如果输入变量的两个匹配来自表的位于同一行的两个变量,它将返回一条消息,否则返回另一个消息。 我怎样才能做到这一点?到目前为止,这是我的代码:
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error(); }
//安全性的转义变量
$numero_cedula = mysqli_real_escape_string($con, $_POST['numero_cedula']);
$codigo= mysqli_real_escape_string($con, $_POST['codigo']);
$sql1="select
Numero Cedula from Teste where
Numero Cedula =$numero_cedula";
mysqli_query($con,$sql1);
$sql2="select
{Codigo {1}} {Codigo {1}}
from Teste where
答案 0 :(得分:0)
AND
子句WHERE
mysqli_num_rows
if()
逻辑。
if (mysqli_connect_errno()) {
echo "Failed to connect to MySQL: " . mysqli_connect_error();
}
// escape variables for security
$numero_cedula = mysqli_real_escape_string($con, $_POST['numero_cedula']);
$codigo = mysqli_real_escape_string($con, $_POST['codigo']);
$sql1 = "SELECT `Numero Cedula`
FROM Teste
WHERE `Numero Cedula`=$numero_cedula
AND `Codigo`=$codigo";
$objGet = mysqli_query($con, $sql1);
if( mysqli_num_rows($objGet) > 0 ) {
echo "Duplicate";
} else {
echo "Not a duplicate";
}