2015-09-20 28 views
0

我正在一個項目中,必須將一些GET請求傳遞給PHP腳本,並且必須根據傳遞的參數生成新的HTML頁面。PHP-GET請求和HTML生成器 - 安全最佳實踐

一個例子: 變量經由GET請求傳遞:

Title > 'example' 
    Videoid > 'video-id' 
    type  > the type of the page (landing page, contact form, etc) 
    output: landing page that has example as title, and post the tube video,etc. 

然後,該腳本生成使用這些參數的着陸頁。

只要HTML從PHP注入頁面, 我想知道從安全角度來看,最好的解決方案是實現該腳本。

回答

1

正確逃吧,讓你不支持Java腳本注射〜任何邪惡 - 這應該只是罰款:

<pre> 
<?php 
ob_start(); 
var_dump($_GET); 
echo htmlentities(ob_get_clean(), ENT_QUOTES | ENT_HTML401 | ENT_SUBSTITUTE, 'UTF-8', true); 
?> 
</pre>