0
<?php  

require "includes/config.php";
require "includes/header.php";

$query = mysqli_query($conn, "SELECT * FROM post ORDER BY id DESC");

?>

This Is The top of index.php .
.
.
.

include "includes/header.php";
include "includes/config.php";

$detail_id = $_GET["id"];
$query = mysqli_query($conn, "SELECT * FROM post WHERE post.id = '$detail_id'");
$row_detail = mysqli_fetch_array($query)

?>

This is the top of detail.php .
.
.
.

<a href="index.php?detail=<?php echo $row["id"]; ?>">

Link to go to detail.php .
.
.
.
The problem is when I click on the link, I'm redirected to index (no change), not to detail.php. Can you solve this problem? Thank you.

  • This might be too obvious, but shouldn't your link go to `detail.php?detail=` instead of to `index.php?details=`? – rickdenhaan Mar 18 '18 at 00:00
  • in your address bar after clicking the link, what is the URL? Any value after detail= ? Inspect the page and look at the link, is the URL correct? – Andrew Mar 18 '18 at 00:05
  • "index.php?detail=1" – Aqwam Hizbal Mar 18 '18 at 00:24
  • [Little Bobby](http://bobby-tables.com/) says [**your script is at risk for SQL Injection Attacks**](http://stackoverflow.com/questions/60174/how-can-i-prevent-sql-injection-in-php). Learn about [prepared](http://en.wikipedia.org/wiki/Prepared_statement) statements for [MySQLi](http://php.net/manual/en/mysqli.quickstart.prepared-statements.php). Even [escaping the string](http://stackoverflow.com/questions/5741187/sql-injection-that-gets-around-mysql-real-escape-string) is not safe! – rollstuhlfahrer Mar 18 '18 at 00:25

1 Answers1

0

Your link is index.php?detail=, this means detail will be available in $_GET

But you are grabbing the parameter with $detail_id = $_GET["id"];

Change it to $detail_id = $_GET["detail"];

You could also try some basic debugging, by var_dump($_GET) and looking at what's in it.

Andrew
  • 18,680
  • 13
  • 103
  • 118