close

http://www.onepiece.is-great.net/test/ex17_%E5%BF%83%E6%83%85%E6%97%A5%E8%A8%98/PHA01-1.php

 

<body>
<?php
$szUrl=$_SERVER['PHP_SELF'];
$szPathImg="images";

echo "<html>";
if ($_SERVER["REQUEST_METHOD"] == "POST")
{
   $sName=trim($_POST["sName"]);
   $sTitle=trim($_POST["sTitle"]);
   $sFriends=trim($_POST["sFriends"]);
   $sMemo=trim($_POST["sMemo"]);
   $nWeather=$_POST["bWeather"];
   $arWeather=array("晴天","陰天","雨天");
   $sWeather=$arWeather[$nWeather];

   if (($sName == "") || ($sTitle == "") || ($sFriends == "") || ($sMemo == ""))
      printf ("<head>
                    <title>資料輸入不全</title>
                </head>
                <body>
                    <FONT SIZE='4' COLOR='#FF0000'>%s</FONT>
                </body>","您可能有某些資料沒有填寫,請您檢查後再試一次......");
   else
   {
      $doc=<<<ENDOFDOC
      <HEAD>
      <STYLE type="text/css">
      <!--
         .Memo { font-size: 18px; color: #0066FF;    margin-left: 2cm; padding-top:0.5cm; line-height:0.6cm}
      -->
      </STYLE>
      </HEAD>
ENDOFDOC;
      echo $doc;

      $sToday=date("Y/M/d",time());
      $sMemo=htmlspecialchars(stripslashes($sMemo));

      $doc=<<<ENDOFDOC
*------------------------------------------------*
     日期:$sToday      心情天氣:$sWeather
   --------------------------------------------
     標題:$sTitle
   --------------------------------------------
     心情記事:
   --------------------------------------------
     $sMemo
   --------------------------------------------
     分享好友:$sFriends
*------------------------------------------------*

ENDOFDOC;
      $outMemo=numberContent($doc);
      printf("<BR/><BR/><DIV class='Memo'>%s</DIV>",nl2br($outMemo));
   }
}
else
{
   $doc=<<<ENDOFDOC
   <HEAD>
   <STYLE type="text/css">
   <!--
      .Title {font-size: 38px; color: #DD701E; font-style: italic; padding-top:0.5cm}
      .Table {font-family: "新細明體"; font-size: 24px; color: #BC5034; margin-left: 2cm; }
      .Content { font-family: "新細明體";    font-size: 32px; color: #0066FF;    margin-left: 2cm; padding-top:0.5cm}
      .Button {font-size:18px; color: #669900; padding-top: 0.2cm; padding-bottom: 0.2cm; margin-top: 0.6cm; margin-left: 12cm}
   -->
   </STYLE>
   </HEAD>
   <P CLASS="Title">熊的異想世界</P>
   <HR CLASS="Title" ALIGN="LEFT" WIDTH="60%" SIZE="5" />
   <DIV CLASS="Content">個人心情記事簿......</DIV><BR/>

   <FORM METHOD=POST ACTION="">
   <TABLE CLASS="Table" CELLPADDING="5" CELLSPACING="5">
   <TR>
      <TD>心情標題</TD>
      <TD><INPUT TYPE="text" NAME="sTitle" SIZE="50"></TD>
   </TR>
   <TR>
      <TD>心情天氣</TD>
      <TD>
         <INPUT NAME="bWeather" TYPE="RADIO" VALUE="0" CHECKED> <IMG SRC="$szPathImg/weather_01.jpg">   
          <INPUT NAME="bWeather" TYPE="RADIO" VALUE="1"> <IMG SRC="$szPathImg/weather_02.jpg">   
           <INPUT NAME="bWeather" TYPE="RADIO" VALUE="2"> <IMG SRC="$szPathImg/weather_03.jpg">   
      </TD>
   </TR>
   <TR>
      <TD>心情記事</TD>
      <TD><TEXTAREA NAME="sMemo" ROWS="12" COLS="60"></TEXTAREA></TD>
   </TR>
    <TR>
      <TD>與好友分享</TD>
      <TD><INPUT TYPE="text" NAME="sFriends" SIZE="40"></TD>
   </TR>
   </TABLE>
   <HR CLASS="Title" ALIGN="LEFT" WIDTH="60%" SIZE="5" />
   <INPUT TYPE="submit" VALUE="寫下來吧!" CLASS="Button">
   <INPUT TYPE="HIDDEN" NAME="sName" VALUE="陳孔熊">
   </FORM>
ENDOFDOC;
   echo $doc;
}
echo "</html>";


function numberContent($doc)
{
   $nCount=0;
   $sNumData="";
   $doc=trim($doc);
   $arData=explode("\n",$doc);
   foreach ($arData as $sLine)
         $sNumData.=sprintf("%d: %s\n",++$nCount, $sLine);
   return $sNumData;
}

?>

</body>

 

<body>
<?php
    error_reporting(E_ALL^E_DEPRECATED);
   //1.日期
   $sToday=date("Y/M/d",time());
   //2.天氣
   $nWeather=$_POST["bWeather"];
   $arWeather=array("晴天","陰天","雨天");
   $sWeather=$arWeather[$nWeather];
   //3.標題
   $sTitle=$_POST["sTitle"];
   //4.記事
   $sMemo=$_POST["sMemo"];
   //5.朋友
   $sFriends=$_POST["sFriends"];
?>
<DIV class='Memo'>
*------------------------------------------------*<BR/>
     日期:<?php echo $sToday ?>    心情天氣:<?php echo $sWeather ?><BR/>
   --------------------------------------------<BR/>
     標題:<?php echo $sTitle ?><BR/>
   --------------------------------------------<BR/>
     心情記事:<BR/>
   --------------------------------------------<BR/>
     <?php echo $sMemo ?><BR/>
   --------------------------------------------<BR/>
     分享好友:<?php echo $sFriends ?><BR/>
*------------------------------------------------*<BR/>
</DIV>
 

arrow
arrow
    文章標籤
    php
    全站熱搜

    陰界黑幫 發表在 痞客邦 留言(0) 人氣()