svnno****@sourc*****
svnno****@sourc*****
2011年 5月 6日 (金) 01:54:14 JST
Revision: 32 http://sourceforge.jp/projects/smartupload/svn/view?view=rev&revision=32 Author: hryksbt Date: 2011-05-06 01:54:13 +0900 (Fri, 06 May 2011) Log Message: ----------- フォームの項目をいくつか追加 ログインに対するエラーチェックを追加 Modified Paths: -------------- trunk/SmartUpload/main.php trunk/SmartUpload/upload_file.php trunk/SmartUpload/upload_form.php trunk/SmartUpload/user_add.php trunk/SmartUpload/user_form.php Added Paths: ----------- trunk/SmartUpload/mod_user.php -------------- next part -------------- Modified: trunk/SmartUpload/main.php =================================================================== --- trunk/SmartUpload/main.php 2011-05-04 17:05:28 UTC (rev 31) +++ trunk/SmartUpload/main.php 2011-05-05 16:54:13 UTC (rev 32) @@ -7,4 +7,12 @@ * */ session_start(); -?> \ No newline at end of file +?> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> +<title>SmartUpload</title> +</head> +<body> +</body> +</html> \ No newline at end of file Added: trunk/SmartUpload/mod_user.php =================================================================== --- trunk/SmartUpload/mod_user.php (rev 0) +++ trunk/SmartUpload/mod_user.php 2011-05-05 16:54:13 UTC (rev 32) @@ -0,0 +1,18 @@ +<?php +/* + * SmartUpload/mod_user.php + * @author Hiroyuki Shibata + * 2011/05/5 + * Rev 1.0 + * + */ + session_start(); +?> +<html> +<head> +<meta http-equiv="content-type" content="text/html; charset=UTF-8" /> +<title>SmartUpload</title> +</head> +<body> +</body> +</html> \ No newline at end of file Modified: trunk/SmartUpload/upload_file.php =================================================================== --- trunk/SmartUpload/upload_file.php 2011-05-04 17:05:28 UTC (rev 31) +++ trunk/SmartUpload/upload_file.php 2011-05-05 16:54:13 UTC (rev 32) @@ -2,7 +2,7 @@ /* * SmartUpload/upload_file.php * @author Hiroyuki Shibata - * 2011/04/26 + * 2011/05/05 * Rev 1.0 * */ @@ -25,8 +25,12 @@ $updir = "./data/"; + $contentname = $_REQUEST["category"]; $filename = $_FILES['upfile']['name']; $filesize = filesize($_FILES['upfile']['tmp_name']); + $username = $_SESSION["id"]; + $category = $_REQUEST["category"]; + $commnet = $_REQUEST["comment"]; if(move_uploaded_file($_FILES['upfile']['tmp_name'], $updir.$filename)==FALSE) { @@ -40,24 +44,40 @@ // データベース処理 $stmt = $db->prepare( - "INSERT INTO data_info (filename, uploaddate, data_size) VALUES(? ,now() ,?)"); + "INSERT INTO data_info ( + contentname, + filename, + uploaddate, + username, + data_size, + category, + comment + ) VALUES (?, ? ,now() ,? ,? ,? ,?)"); - $stmt->bindParam(1,$filename); - $stmt->bindParam(2,$filesize); + $stmt->bindParam(1, $contentname); + $stmt->bindParam(2, $filename); + $stmt->bindParam(3, $username); + $stmt->bindParam(4, $filesize); + $stmt->bindParam(5, $category); + $stmt->bindParam(6, $commnet); $stmt->execute(); print('<br>'); - $sql ='select * from data_info'; + /* + $sql = $db->prepare('select * from data_info where filename = ?'); + $sql->execute(array($filename)); + $row = $sql->fetch(PDO::FETCH_ASSOC); - foreach ($db->query($sql) as $row) { + print($row['contentname']." "); + print($row['filename']." "); + print($row['uploaddate']." "); + print($row['username']." "); + print($row['data_size']." "); + print($row['category']." "); + print($row['comment'].'<br />'); + */ - print($row['filename']." "); - print($row['uploaddate']." "); - print($row['data_size'].'<br />'); - - } - } ?> Modified: trunk/SmartUpload/upload_form.php =================================================================== --- trunk/SmartUpload/upload_form.php 2011-05-04 17:05:28 UTC (rev 31) +++ trunk/SmartUpload/upload_form.php 2011-05-05 16:54:13 UTC (rev 32) @@ -2,7 +2,7 @@ /* * SmartUpload/upload_form.php * @author Hiroyuki Shibata - * 2011/05/4 + * 2011/05/5 * Rev 1.0 * */ @@ -21,8 +21,25 @@ <form method="post" enctype="multipart/form-data" action="upload_file.php"> <pre> コンテンツ名 :<input type="text" name="mail"> ※ 全角32文字以内<br> -カテゴリ :<input type="text" name="mail"><br> -コメント :<input type="text" name="mail"> ※ 全角512文字以内<br> +カテゴリ :<select name="category"> +<?php + require_once("include/database.php"); + + $value = 0; + + $stmt = $db->prepare("SELECT * FROM category"); + $stmt->execute(); + + while ($row = $stmt->fetch(PDO::FETCH_ASSOC)) { +?> + <option value="<?php print($row["cat_number"]); ?>"> + <?php print($row["cat_name"]); ?> + </option> +<?php + } +?> + </select> +コメント :<textarea name="comment" rows=3 cols=50 wrap="virtual"></textarea> ※ 全角512文字以内<br> ファイル :<input type="file" name="upfile"><br> <input type="submit" value="アップロード"> <input type="reset" value="リセット"> </pre> Modified: trunk/SmartUpload/user_add.php =================================================================== --- trunk/SmartUpload/user_add.php 2011-05-04 17:05:28 UTC (rev 31) +++ trunk/SmartUpload/user_add.php 2011-05-05 16:54:13 UTC (rev 32) @@ -2,7 +2,7 @@ /* * SmartUpload/user_add.php * @author Hiroyuki Shibata - * 2011/04/26 + * 2011/05/05 * Rev 1.0 * */ @@ -14,43 +14,51 @@ <title>SmartUpload</title> </head> <body> - <p> - <b>登録完了</b> - </p> <?php + // メイン処理 // require_once("include/database.php"); try{ - // DBに登録 // - $stmt = $db->prepare( - "INSERT INTO user_info ( - userid, - password, - fullname, - country_code, - add_date, - email, - frag - ) VALUES ( ?, ?, ?, ?, now(), ?, 0)" - ); + if ($_SESSION["id"]) { - $stmt->bindParam(1,$_REQUEST["id"]); - $stmt->bindParam(2,$_REQUEST["pass"]); - $stmt->bindParam(3,$_REQUEST["name"]); - $stmt->bindParam(4,$_REQUEST["country"]); - $stmt->bindParam(5,$_REQUEST["mail"]); - $stmt->execute(); + print("すでにログインしています"); - // 登録成功を表示 // - $sql ='select userid from user_info'; + } else { + ?> + <p> + <b>登録完了</b> + </p> + <?php + // DBに登録 // + $stmt = $db->prepare( + "INSERT INTO user_info ( + userid, + password, + fullname, + country_code, + add_date, + email, + frag + ) VALUES ( ?, ?, ?, ?, now(), ?, 0)" + ); - foreach ($db->query($sql) as $row) { + $stmt->bindParam(1,$_REQUEST["id"]); + $stmt->bindParam(2,$_REQUEST["pass"]); + $stmt->bindParam(3,$_REQUEST["name"]); + $stmt->bindParam(4,$_REQUEST["country"]); + $stmt->bindParam(5,$_REQUEST["mail"]); + $stmt->execute(); - print($row['userid']." "."が登録されました。"); + // 登録成功を表示 // + $sql ='select userid from user_info'; + foreach ($db->query($sql) as $row) { + + print($row['userid']." "."が登録されました。"); + } } } catch (PDOException $e) { Modified: trunk/SmartUpload/user_form.php =================================================================== --- trunk/SmartUpload/user_form.php 2011-05-04 17:05:28 UTC (rev 31) +++ trunk/SmartUpload/user_form.php 2011-05-05 16:54:13 UTC (rev 32) @@ -2,11 +2,11 @@ /* * SmartUpload/user_form.php * @author Hiroyuki Shibata - * 2011/05/01 + * 2011/05/05 * Rev 1.0 * */ - session_start(); +session_start(); ?> <html> <head> @@ -14,11 +14,18 @@ <title>SmartUpload</title> </head> <body> - <p> - <b>ユーザー登録</b> - </p> - <form name="user_form" action="./user_add.php" method="post"> -<pre> + <?php + if ($_SESSION["id"]) { + + print("すでにログインしています"); + + } else { + ?> + <p> + <b>ユーザー登録</b> + </p> + <form name="user_form" action="./user_add.php" method="post"> + <pre> ID(アカウント) :<input type="text" name="id"> ※ 半角32文字以内<br> パスワード :<input type="password" name="pass"> ※ 半角英数字32文字以内<br> 氏名 :<input type="text" name="name"> ※ 全角32文字以内(半角64文字以内)<br> @@ -33,8 +40,12 @@ <br> メールアドレス :<input type="text" name="mail"> ※ 半角64文字以内<br> -<input type="submit" class="update" value="登録" /> <input type="reset" value="リセット"> -</pre> - </form> +<input type="submit" class="update" value="登録" /> <input type="reset" + value="リセット"> + </pre> + </form> + <?php + } + ?> </body> </html>