Commit ceca82c6 authored by 君塚 悠's avatar 君塚 悠

プログラム修正(コメント追記)

parent 18afeb0e
<!-- helloworld -->
<html>
<head>
<title>さぁ、始まりです!</title>
......
<!-- 氏名を入力するフォーム画面 -->
<html>
<head>
<title>フォーム情報を取得する</title>
......
<!-- input.phpにて入力された氏名を出力する -->
<html>
<head>
<title>フォーム情報を取得する</title>
......
<!-- クエリ情報から、表示する文字列を選択する -->
<html>
<head>
<title>クエリ情報を取得する</title>
......
<!-- ヘッダの情報を取得し、配列宣言で指定したヘッダ名の値を出力する -->
<html>
<head>
<title>ヘッダ情報の取得</title>
</head>
</html>
<body>
<h1 style="background: #CCCCCC">ヘッダ情報の取得</h1>
<h1 style="background: #cccccc">ヘッダ情報の取得</h1>
<table border="0">
<?php
// 欲しいヘッダ情報を指定する
$aryHeader=array("HTTP_USER_AGENT",
"HTTP_ACEPT_LANGUAGE","HTTP_PEFERER");
// 欲しいヘッダ情報名及び欲しいヘッダ情報を出力する
foreach ($aryHeader as $name) {
?>
<rt>
......@@ -21,7 +24,6 @@ foreach ($aryHeader as $name) {
}
?>
</table>
</form>
</body>
</html>
\ No newline at end of file
<!-- email情報を送信する -->
<html>
<head>
<title>クッキーでデータを記録する</title>
......
<!-- cookie.phpにて送られたemail情報をクッキーで90日の間記録する。 -->
<html>
<head>
<title>クッキーでデータを記録する</title>
......
<?php
//おみくじデータの用意
// おみくじデータの用意
$aryTitle=array("大吉","中吉","小吉","吉","凶");
$aryKuji =array(
"大吉"=>"ラッキー!今日は超ハッピー!!",
......@@ -7,9 +7,10 @@ $aryKuji =array(
"小吉"=>"小さな幸せを大事にネ。",
"吉"=>"今日も無難に良い1日を...",
"凶"=>"ムムムな今日は大人しく過ごしましょう。");
//おみくじのシャッフル
// おみくじのシャッフル
shuffle($aryTitle);
// 配列の先頭に来たおみくじを出力する
echo $aryTitle[0], "\n";
echo $aryKuji[$aryTitle[0]], "\n";
......
......@@ -38,7 +38,10 @@
<!-- </html> -->
<?php
// $answerで指定した数を当てる。
// 指定していない場合は、1~100までの数字でランダムに決定する
// 外れた場合は、数が大きいか小さいかが出力され、
// 再度数字を入力できる。
$answer = 30;
if (is_null($answer)) {
mt_srand(microtime()*1000000);
......
<?php
// カレンダーを作成する
// クエリ情報から年月を特定し、出力する
// 情報に年月の記載が無かった場合は現在の年月にする
if ($_GET['num']=='') {
$today_year =date("Y");
$today_month=date("n");
......@@ -8,7 +12,9 @@ if ($_GET['num']=='') {
$today_year = date("Y", $timestamp);
$today_month =date("n", $timestamp);
}
// 現在の年月のタイムスタンプを作成
$current = mktime(0, 0, 0, $today_month, 1, $today_year);
// 初日の曜日
$first_day =date("w",$current);
$last_day = date("t",$current);
?>
......@@ -24,12 +30,17 @@ $last_day = date("t",$current);
</tr>
<?php
for ($i = 1; $i <= $first_day + $last_day; $i++) {
// 一週間分を書き始めるために改行する
if ($i % 7 == 1) {print ("<tr>");}
// 初日の曜日より月初めの曜日が若ければ、空白を出力する
if($i > $first_day) {
print("<td>".($i-$first_day)."</td>");
} else {
print("<td> & nbsp;</td>");
}
// 一週間分記載できたなら行を終える
if ($i % 7 == 0) {print("</tr>"); }
}
?>
......
<!-- メール送信フォームを表示する
入力された情報はsedmail.phpに送られ、
メールが送信される -->
<html>
<head>
<title>10日で覚えるPHP5入門教室(アンケート)</title>
</head>
<body>
<!-- タイトル -->
<h1 style="background: #cccccc">
10日で覚えるPHP5入門教室(アンケート)</h1>
10日で覚えるPHP5入門教室(アンケート)</h1>
<form method="POST" action="sendmail.php">
<input type="hidden" name="_email"
value="CQW15204@nifty.com" />
<input type="hidden" name="_subject"
value="10日で覚えるPHP5入門教室" />
<input type="hidden" name="_subject"
value="<?php print($SERVER['PHP']);?>" />
<input type="hidden" name="_email" value="CQW15204@nifty.com" />
<input type="hidden" name="_subject" value="10日で覚えるPHP5入門教室" />
<input type="hidden" name="_result"
value="<?php print($_SERVER['PHP_SELF']);?>" />
<table border="0">
<tr>
<th align="right"名前</th>
<td><input type="text" name="_from"
size="50" maxlength="255" /></td>
<td><input type="text" name="_from" size="20" maxlength="30" /></td>
</tr><tr>
<th align="right"E-Mail:</th>
<td><input type="text" name="_from" size="50" maxlength="255" /></td>
</tr><tr>
<th align="right" valign="top">自由記入欄:</th>
<td><textarea name="memo" rows="5" cols="50">
</textarea></td>
<td><textarea name="memo" rows="5" cols="50"></textarea></td>
</tr>
</table
</table>
<input type="submit" value="送信" />
<input type="reset"valuse="クリア" />
</form>
</body>
</html>
\ No newline at end of file
</html>
<?php
// mail_input.phpから受け取った情報を元に、
// メールを作成、送信する。
// 送信後、mail_input.phpにリダイレクトする。
//
$header_info="Form: ".$_POST['_from']."
\nContent-Type: text/plain;carset
=ISO-2022-JP\nX-Mailer: PHP/".phpversion();
......
<!-- ファイルをアップロードするためのフォームを表示し、
upload_save.phpに渡す -->
<html>
<head>
<title>ファイルのアップロード</title>
......
<?php
// upload.phpから受け取ったファイルを保存する。
// 保存したファイルの概要を表示する。
$error_flag=FALSE;
$name="/\doc/".$_FILES['upload_file']['name'];
//アップロード時に行なうエラーチェック
//アップしようとしているファイルが既にある && 上書き禁止 -> エラー
if (file_exists($name)==TRUE & $_POST['forbidden']==1) {
$error_flag=TRUE;
$error_msg="同名のファイルが存在します。";
// $_FILEは[要素名] [情報名]で成り立っており、
// [要素名]は
// <input type="file" name="upload_file size="70"><br /> のname
// 情報名には、name, type, size, tmp_name, errorが存在している。
// errorには、アップロード時に発生したエラーが格納される。
// 以下は、エラーメッセージに
} elseif ($_FILES['upload_file']['error'] != UPLOAD_ERR_OK) {
$error_flag=TRUE;
switch ($_FILES['upload']['error']) {
......@@ -24,12 +37,16 @@ if (file_exists($name)==TRUE & $_POST['forbidden']==1) {
break;
}
}
// エラーがあった場合、エラーメッセージを表示する。
// 正常であれば、
if ($error_flag) {
print("<div style='color:Red;'>".$error_msg."</div>");
} else {
move_uploaded_file($_FILES['upload_file']['tmp_name'],$name);
}
?>
<!-- アップロードされたファイルの概要一覧を出力する -->
<html>
<head>
<title>ファイルのアップロード</title>
......@@ -46,6 +63,8 @@ $o_dir=opendir("./doc/");
while ($file=readdir($o_dir)) {
if ($file!="." && $file!="..") {
?>
<!-- ファイル名、ファイル容量、ファイルをアップロードした日付、
ファイルを更新した日付を出力する -->
<tr>
<td><a href="./doc/<?php print($file); ?>"><?php print($file); ?> </a></td>
<td><?php print(round(filesize("./doc/".$file)/1024)); ?>KB</td>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment