dpbz14739 2019-02-20 00:29
浏览 51

编写一个PHP脚本,在将其输入MySQL数据库之前检查值是否已经发生过n次[重复]

I'm writing a PHP script that take in a set of inputs and puts it into a mySQL database. Currently, it just takes a set of inputs and enters it into a MYSQL database. Here's my code below.

<?php

// Create connection
$con=mysqli_connect("localhost","username","password","data");

$username = $_POST['a'];
$report = $_POST['b'];

// This SQL statement inserts data into table 'Lion_Datahere
$sql = "INSERT INTO `User_Reports` (`user_name`, `report`) VALUES ('$username', '$report')";

if ($con->query($sql) === TRUE) {
echo "New record created successfully";
}

// Close connections
mysqli_close($con);
?>

I want to modify this script so that it only allows the user to submit a report up to three times. How do I change this so that before inserting it checks if the variable user_id occurs more than three times in the column user_name, and discards it if the user has already hit the limit?

</div>
  • 写回答

0条回答 默认 最新

    报告相同问题?

    悬赏问题

    • ¥15 mmocr的训练错误,结果全为0
    • ¥15 python的qt5界面
    • ¥15 无线电能传输系统MATLAB仿真问题
    • ¥50 如何用脚本实现输入法的热键设置
    • ¥20 我想使用一些网络协议或者部分协议也行,主要想实现类似于traceroute的一定步长内的路由拓扑功能
    • ¥30 深度学习,前后端连接
    • ¥15 孟德尔随机化结果不一致
    • ¥15 apm2.8飞控罗盘bad health,加速度计校准失败
    • ¥15 求解O-S方程的特征值问题给出边界层布拉休斯平行流的中性曲线
    • ¥15 谁有desed数据集呀