私は、特定の変数に従ってデータを表示するためにURLパラメータにPOSTメソッドを使用でき、GETメソッドを使用する方法を知っていますが、 POSTメソッドを使用して、このようなURLの部分を隠すことができます。POSTメソッドを使用してURLパラメータを非表示にする
/data.php?parameter=1234
実際のURLパラメータの違いは何ですか?以下
私はそうのようなIDに係るdata.phpファイルへのリンクを生成する特定のリンク別のページに
<?php
//This includes the variables, adjusted within the 'config.php file' and the functions from the 'functions.php' - the config variables are adjusted prior to anything else.
require('configs/config.php');
require('configs/functions.php');
//This is the actual interaction with the database, according to the id.
$query = mysql_query("SELECT * FROM table WHERE id=" .$_GET['id'] . ";") or die("An error has occurred");
//This re-directs to an error page the user preventing them from viewing the page if there are no rows with data equal to the query.
if(mysql_num_rows($query) < 1)
{
header('Location: 404.php');
exit;
}
//Here each cell in the database is fetched and assigned a variable.
while($row = mysql_fetch_array($query))
{
$id = $row['id'];
$title = $row['title'];
$month = $row['month'];
$day = $row['day'];
$photo = $row['photo'];
$text = $row['text'];
}
?>
のIDに従ってデータベースからデータをフェッチするいくつかのコードである。
<a href="post.php?id=<?php echo $content['id']; ?>"><?php echo $content['title']; ?></a>
私はURLパラメータを隠すために、POSTメソッドを使用することについては行くだろうか、上記のコードを介して起こり得る潜在的なSQLインジェクションがあることを忘れる、または少なくともこのようにそれらを表示しない:
http://example.com/data.php?id=1
小さなサイドノート '' 'するmysql_query(からフォームにパラメータをPOSTを削除し追加し、同じ問題を持っていた "テーブルSELECT * FROM WHERE ID ="。$ _ GET [ 'ID'] ";") '' 'はSQLインジェクションに対して脆弱ですので、オンラインにして、データベースに重要なデータが含まれている場合は注意してください。 – Mason