php - 如何使用php和html从表单输入框中检查用户的输入对应于mysql中数据库的结果
问题描述
这就是问题
用户应该输入一个代码,该代码应该由数据库中的 SQL 语句使用 Php 进行验证。
//此代码应检查用户在确认输入字段中输入的代码是否与数据库中的代码相同。
//它从不同的表中收集数据库中的不同字段
//这里是我应该输入确认的表单输入框
代码
<div class="input-group">
<span class="input-group-addon">
<i class="fa fa-money"></i></span>
//this is the entry box named con_code
<input type="text" name="con_code" id="con_code" class="form-control" required="required" placeholder="Enter you Confirmation Code" />
</div>
php 语句
<?php
// the SQL statement to check from the tables
$check="SELECT payment.instname, payment.firstname, payment.lastname, payment.email, payment.amount, payment.category, payment.confcode, payment.tdate, transactions.transactioncode FROM payment, transactions WHERE payment.confcode='con_code'";
//query to the db
$result= mysqli_query($conn,$check);
//checks whether the SQL statement is true
if($result-> num_rows > 0){
//$conf=$row['confcode'];
//$amt=$row['amount'];
//$date=$row['tdate'];
$msg = "Payment has been Confirmed!!";
//output if the condition is true
echo $msg;
}
else{
//output if the condition is false
$ms="Payment Code does not exist!!";
echo $ms;
}
?>
解决方案
简化:- !!!没有安全性!
$con_code = $_POST['con_code'];
$check="SELECT payment.instname, payment.firstname, payment.lastname, payment.email, payment.amount,payment.category, payment.confcode, payment.tdate, transactions.transactioncode
FROM payment, transactions
WHERE payment.confcode='".$con_code."'";
推荐阅读
- python - 在 Python 中包含 for 循环的函数中是否可以有多个条件?
- kubernetes - 在 Kubernetes 部署文件中生成动态密钥名称
- asp.net-core - 401 使用 Azure AD 在 .NET Core 3.1 中仅使用不记名令牌进行身份验证
- c# - 如何防止积分翻倍?
- function - 尝试添加列度量时 DAX NORM.S.INV 返回错误
- python - 带权重的 numpy 随机选择的 2D 版本
- r - 根据 tabPanel 选择从数据库获取数据。闪亮
- javascript - 如何防止过滤器制作空数组?
- exception - 当对用户定义的异常使用“raise”时,它在“try”下不起作用
- sql - 忽略给定单词的大小写敏感