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