SmartyでPOSTの値を取得@PHP
SmartyでPOSTの値を取得を取得します。
以下は、test.phpにidとnameをPOSTしています。
{$smarty.post.id}、{$smarty.post.name}で値を取得できます。
form
<form method="post" action="test.php">
<input type="text" name="id" size="">
<input type="text" name="name" size="">
<input type="submit" value="実行">
</form>
|
test.php
<?php
//Smartyライブラリ
require '../libs/Smarty.class.php';
//生成
$smarty = new Smarty;
//テンプレート「test.tbl」を呼び出して表示
$smarty->display('test.tpl');
?>
|
test.tbl
<html>
<head>
</head>
<body>
ID:{$smarty.post.id} <BR>
NAME:{$smarty.post.name}
</body>
</html>
|