PHP(4) Search a tag

処理内容

tagを検索する実装

  1. tag Search form
  2. tag Search Action
    1. Search file database for a tag
    2. return value

検索フォーム

GetValueForm.phpと保存してください。

<h3> Search database for a tag</h3>
<form action="GetValueAction.php" method="post" enctype=application/x-www-form-urlencoded>
   <p>Tag:<input type="text" name="tag" /></p>
   <input type="hidden" name="fmt" value="html">
   <input type="submit" value="Get value">
</form>

 

検索Action

  • tag Search Action
    1. Search file database for a tag
    2. return value

GetValueAction.phpと保存してください。

// JSON_API , Post Parameters : tag
$tagName  = $_REQUEST['tag'];
$tagValue = '';
is_file($tagName . ".txt") && ($tagValue = file_get_contents($tagName . ".txt"));
header('Cache-Control: no-cache, must-revalidate');
header('Expires: Mon, 26 Jul 1997 05:00:00 GMT');
header('Content-type: application/json');
echo json_encode(array(
    "VALUE",
    $tagName,
    $tagValue
));

 

 

Leave a Reply

Your email address will not be published. Required fields are marked *