-3
<?php
include "global_database_function.php"; //include config file
$nama_kategori = $_GET['nama_kategori']; //get from previous link
//global $nama_kategori; 
//i can't use global $name_kategori

$idkategori = $_GET['idkategori'];
?>
<html>
<head>
</head>
<body>
<?php
//continue only if $_POST is set and it is a Ajax request
if(isset($_POST) && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{   
  //here is the code i try to show, i try to use:
   htmlspecialchars($nama_kategori);
}
?>
</body>
</html>

如果我放在htmlspecialchars($nama_kategori);body 和 之间if(isset($_POST) && isset, 的值$nama_kategori是可见的。

4

1 回答 1

0

让它存储到会话中以备将来使用

$nama_kategori = $_GET['nama_kategori'];
session_start();
$_SESSION['t']=$nama_kategori;

并在需要时

if(isset($_POST) && isset($_SERVER['HTTP_X_REQUESTED_WITH']) && strtolower($_SERVER['HTTP_X_REQUESTED_WITH']) == 'xmlhttprequest')
{ 
session_start();  
echo $_SESSION['t'];
}
于 2015-10-01T10:44:01.393 回答