ようこそ! このブログは、PHPとMysqlを使って作成したオリジナルプログラムを、QHMに読み込んで表示させています。

edittopic.php

FrontPage

edittopic.phpのソースコード

<?
require("MySmarty.class.php");
require('Settings.class.php');
require('Categories.class.php');
require('Topic.class.php');

$smarty = new MySmarty();
$settings  = new Settings;
$categories  = new Categories;
$topic  = new Topic;

session_start();
$id = $_SESSION['id'];
$pass = $_SESSION['pass'];
// ユーザチェック
if( ( $id == '' ) || ( !$settings->isValidUser ($id,$pass) ) ){
	header("Location: login.php" );
	exit;
}

$settings->loadSettings();

if( $_SERVER['REQUEST_METHOD'] == 'GET' ){
	if( !isset( $_GET['topicid'] ) || ( $_GET ['topicid'] == 0 ) ) {
		// 新規トピックの編集
		$smarty->assign( "topicid", "0" );
		$smarty->assign( "title" , "" );
		$smarty->assign( "body" , "" );
		$smarty->assign( "fdelete", "" );
	} else {
		$err = $topic->loadTopic( $_GET['topicid'] );
		$err_msg = $topic->errorm;
		$smarty->assign( "topicid", $topic->topicid );
		$smarty->assign( "title" , $topic->title );
		$smarty->assign( "body" , $topic->body  );
		$smarty->assign( "fdelete", $topic->fdelete );
	}
} else {
	
	$smarty->assign('topicid', $_POST['topicid']);
	$smarty->assign('title', $_POST['title']);
	$smarty->assign('body', $_POST['body']);
	$smarty->assign('fdelete', $_POST['fdelete']);
	
	if( $_POST['submit'] != '' ){
//		$err_msg = check_input();
		if( $err_msg == '' ){
			$topic->topicid = $_POST['topicid'];
			$topic->title = $_POST['title'];
			$topic->body = $_POST['body'];
			$topic->catid = $_POST['catid'];
			$topic->fdelete = $_POST['fdelete'];
			$topic->saveTopic();
			$err_msg = $topic->errorm;
		}
		if( $err_msg == '' ){
			$gen_msg = "日記書き込み完了しました。";
		}
	}
}

$smarty->assign('categories_list', $categories- >makeSelect($topic->catid));
$smarty->assign( "maintitle", $settings->maintitle );

$smarty->assign('error_message', $err_msg);

$smarty->assign('general_message', $gen_msg);

if( $topic->topicid == 0 ){
	$smarty->assign('mode', "追加");
} else {
	$smarty->assign('mode', "編集");
}
$smarty->display( "edittopic.html" );

?>

powered by Quick Homepage Maker 4.25
based on PukiWiki 1.4.7 License is GPL. QHM

最新の更新 RSS  Valid XHTML 1.0 Transitional