エラーとして表示されるだけでなく、ページのコンテンツに追加された PHP の戻り値を取得することが可能かどうか疑問に思っています。
現在、フォームが送信されると、次のように生成されます。
私が欲しいのは、フォームが送信され、エラー/成功メッセージが表示されるときに、ページのコンテンツもそこにあるはずです。このような:
これは私のコードです:
if($_POST)
{
$newTopic = $forum->newTopic();
/*
* Return codes:
* 1: No title
*
* 100: Success
*/
switch($newTopic)
{
case 1:
$error = 'You have not entered any title.';
$stop = true;
break;
//If no error = success.
case 100:
$success = "Success! TOpic created";
break;
}
die($error);
}
どうすればこれを入手できますか?
編集:
ページの HTML は次のように生成されます。
loadmodule('forum');
$forum= new Forum;
if(file_exists(HEADER)) { include_once(HEADER); }
if($contents) { print $contents; }
if($_POST)
{
$newTopic = $forum->newTopic();
/*
* Return codes:
* 1: No title
*
* 100: Success
*/
switch($newTopic)
{
case 1:
$error = 'You have not entered any title.';
$stop = true;
break;
//If no error = success.
case 100:
$success = "Success! TOpic created";
break;
}
die($error);
}
if(file_exists(FOOTER)) { include_once(FOOTER); }