【发布时间】:2021-01-06 16:08:56
【问题描述】:
我有这个 PHP 应用程序,用户 Student 可以在其中查看和申请其他用户 Employer 可以发布的实习。 Screenshot of the Student Dashboard。问题是:
如果学生已经申请实习,应限制再次申请。 This is the form when Apply is clicked
这是表单页面的 PHP 代码:
`
$name=$_POST['name'];
$email=$_POST['email'];
$employer=$_POST['employer'];
$title=$_POST['title'];
$query="INSERT INTO student_applications(name,email,employer,job_title) VALUES('$name','$email','$employer','$title')";
$result=mysqli_query($conn,$query);
if($result)
header("Location: student-profile.php");
else
header("Location: register_intern.php");
?>`
【问题讨论】:
-
你听说过sql注入吗?
-
您的代码容易受到SQL injection 攻击。您应该使用mysqli 或PDO 准备好的语句和this post 中所述的绑定参数。
-
这只是一个代码 sn-p 为问题提供上下文
-
@SatyamRaj 人们将 SO 视为示例,因此最好不要在网站上包含不安全的代码,如果存在不安全的代码,则应将其调出以警告任何未来的查看者。
-
您尝试过什么限制访问?使用 cookie 就足够了,还是您已经使用了某种身份验证?
标签: php