php网站的URL注入问题

时间:2016-12-02 10:01:59

标签: php html security

我有HTML网站,我们正在使用PHP代码来管理联系页面。目前,我们正面临来自安全扫描的URL注入警报问题。发现问题在于以下两行PHP代码,但无法验证日期输入。

<div class="field calendar"><input name="contact-arrival" type="date" placeholder="Arrival Date" id="contact-arrival" value="<?php if (isset($_POST['arrival']) && !empty($_POST['arrival'])) { echo $_POST['arrival']; } else { echo '';} ?>" readonly /><i class="fa fa-calendar-o"></i></div>

<div class="field calendar"><input name="contact-departure" type="date" placeholder="Departure Date" id="contact-departure" value="<?php if (isset($_POST['departure']) && !empty($_POST['departure'])) { echo $_POST['departure']; } else { echo '';} ?>" readonly /><i class="fa fa-calendar-o"></i></div>

1 个答案:

答案 0 :(得分:1)

您应该使用htmlentities转义发布的数据:

echo htmlentities($_POST['arrival'], ENT_QUOTES, 'utf-8');

注意:一旦表单发布到PHP脚本,您还应该验证表单数据。

相关问题