溫瑞烘老師的教學歷程檔案(Teaching ePortfolio) - 104-1-資料庫程式設計-進階 - 第12週-建立個人網站-第一步驟
 

資訊管理系
副教授
温瑞烘


歷程檔案 Portfolio


關於我 About Me

第12週-建立個人網站-第一步驟


建立個人網站-第一步驟



第二步驟




第三步驟




建立個人網站分成三個步驟, 黨進入這支程式時, 如果尚未建立網站則新建一個
此時必須要知道是誰要建立網站, 這可由 eplogin.php中的下列敘述傳送 $username
並且一直要保留 $username

  if ($ident=="2") { // 學生端管理介面
      echo "<html><head><title>學生學習歷程網登入頁面</title>
                <link rel='stylesheet' type='text/css' href='style.css'>
                </head>";
      $pglist=array("epcreate.php","eplink.php","epchange.php");
      $namelist=array("建立個人網站","發表文章內容","更改基本資料");
      foreach ($pglist as $key => $pg) {
        $name=$namelist[$key];
        echo "<tr><form method='post' action='$pg' target='middle' ><td>
                  <input class='cmd1' type='submit' name='command' value='$name'>
                  <input type='hidden' name='username' value='$username'>
                  </td></form></tr>";
      }
      echo "</table></center></body></html>";   


新建網站的預設名稱為 
  歡迎參觀 $class_name $student_name 的學習歷程網站(Eportfolio)
預設的網頭 headoid 為 epheader的第一各網頭 oid 

建立個人網站的程式控制區段如下 

<?php
  
  include "epconfig.php";
  $command=$_POST["command"]; 
  if ($command=="建立個人網站" || $command=="返回") {
    display_first_page($conn);
  }
  elseif ($command=="儲存") {
    $id=$_POST["id"];
    if ($id=="1") store_webtitle_page($conn);         //  第一步驟
    elseif ($id=="2") store_headoid_page($conn);  //  第二步驟 
    elseif ($id=="3") store_content_page($conn);   //  第三步驟
    display_first_page($conn);
  }
  mysqli_close($conn); 

 function display_first_page($conn) {
    $username=$_POST["username"]; 
    $sql="select * from epweb where uid='$username' ";
    $result=mysqli_query($conn,$sql);
    $no_of_rows=mysqli_num_rows($result);
    if ($no_of_rows==0) {  // 尚未建立網站
      $weboid=create_web_page($conn,$username);  // 新建網站 傳回 epweb.oid
       // 準備一個 SQL由 epweb取得 oid=$weboid並取出所有欄位
    } else {
       //  準備一個 SQL由epweb取得uid='$username'並取出所有欄位
    }
    echo "<html><head><title>建立個人網站</title>
              <link rel='stylesheet' type='text/css' href='style.css'>
              </head><body><center>
              <table><form method='post' action=''>
              <tr><td class='alt1' colspan=2>步驟 1 --  輸入個人網站的名稱</td></tr>  
              <tr><td class='alt1'>網站名稱</td><td>
              <input type=text name='webtitle' size=80 value='$webtitle'>
              </td></tr></table>
              <input class='cmd' type=submit name='command' value='儲存'>
              <input type=hidden name='username' value='$username'>
              <input type=hidden name='weboid' value='$weboid'>
              <input type=hidden name='id' value='1'><hr></form>";
    
      // 尚有第二步驟的 form 與 第三步驟的 form 
     

 echo "</center></body></html>";

}

 function create_web_page($conn,$username) {
    $sql =" "; //查詢student_no='$username'的班級名稱與學生姓名
  
 
    $webtitle="歡迎參觀 $class_name $student_name 的學習歷程網站(Eportfolio)";

 
    $sql =" ";  //查詢 epheader的第一個 oid
 
    $result=mysqli_query($conn,$sql);
    $myrow=mysqli_fetch_array($result);
    $headoid=$myrow["oid"];
    if ($headoid=="") {
      echo "<script> alert('沒有網頭資料,請通知管理者'); </script>"; die();
    }
    $sql ="    ";  // 插入 epweb
 
    mysqli_query($conn,$sql);
    $weboid=mysqli_insert_id($conn);
    return $weboid;
  }


?>
 






全部共 0則留言
登入帳號密碼代表遵守學術網路規範
 


文章分類 Labels

 


最新文章 Top10

中華科技大學數位化學習歷程 - 意見反應