:::

2-6 admin/main.php

<?php
/*-----------引入檔案區--------------*/
$xoopsOption['template_main'] = "tad_ebook_adm_main.html";
include_once "header.php";
include_once "../function.php";

/*-----------function區--------------*/

//管理電子校刊表單
function ebook_form(){
  global $xoopsTpl , $xoopsDB;

  $ebook_title = "";
  $ebook_post_date = time() + 3600 * 24 * 14;
  $ebook_publish_date = time() + 3600 * 24 * 28;

  //引入表單物件
  include_once(XOOPS_ROOT_PATH."/class/xoopsformloader.php");

  $form = new XoopsThemeForm('電子校刊管理表單', 'ebook', 'main.php', 'post', true);

  $Text = new XoopsFormText('電子校刊標題', 'ebook_title', 200 , 80 , $ebook_title);
  //$Text->setExtra("style='width: 400px; color: white; background-color: #000000;'");
  $Text->setExtra("style='width: 400px;'");
  $Text->setExtra("placeholder='請輸入標題'");

  $form->addElement($Text);


  $DateSelect=new XoopsFormTextDateSelect('投稿截止日', 'ebook_post_date', 15, $ebook_post_date);
  $DateSelect->setExtra("style='width: 100px;'");
  $form->addElement($DateSelect);

  $DateSelect1=new XoopsFormTextDateSelect('出刊日', 'ebook_publish_date', 15, $ebook_publish_date);
  $DateSelect1->setExtra("style='width: 100px;'");
  $form->addElement($DateSelect1);

  $Tray=new XoopsFormElementTray('', '&nbsp;', '');
  $Tray->addElement(new XoopsFormButton('', '', '送出', 'submit'));
  $Tray->addElement(new XoopsFormButton('', '', '清除', 'reset'));
  $form->addElement($Tray);

  $Hidden =new XoopsFormHidden('op', 'insert_ebook');
  $form->addElement($Hidden);

  $ebook_form = $form->render();

  $xoopsTpl->assign('ebook_form' , $ebook_form);
}


//寫入資料庫
function insert_ebook(){
  global $xoopsDB;

  $tbl=$xoopsDB->prefix('tad_ebook');

  $sql="insert into `{$tbl}` (`ebook_title` ,`ebook_post_date` , `ebook_publish_date`) values('{$_POST['ebook_title']}' , '{$_POST['ebook_post_date']}' ,'{$_POST['ebook_publish_date']}')";

  $xoopsDB->query($sql) or die(mysql_error());

}

/*-----------執行動作判斷區----------*/
$op=empty($_REQUEST['op'])?"":$_REQUEST['op'];

switch($op){

  case "insert_ebook":
  insert_ebook();
  header("location:{$_SERVER['PHP_SELF']}");
  break;

  default:
  ebook_form();
  break;
}

/*-----------引入檔案區--------------*/
include_once 'footer.php';
?>

 


:::

搜尋

QR Code 區塊

https%3A%2F%2Ftad0616.cp27.secserverpros.com%2Fmodules%2Ftad_book3%2Fpage.php%3Ftbdsn%3D1128%26tbsn%3D37

書籍目錄

展開 | 闔起

線上使用者

328人線上 (149人在瀏覽線上書籍)

會員: 0

訪客: 328

更多…