PHPで簡単なログインページを作っています。
つまずいているのは、アカウント登録ページです。
メールアドレス、アカウント名、表示名、パスワード それぞれほかのファイルに保存するようにしているんですが、
メールアドレスだけ書き込めません。
他のページでセッションに保存もしていましたが駄目でした。
「メールアドレスの再確認」という<input>を作ってそこからメールアドレスを入手しようとしましたが駄目でした。
error
1Warning: touch(): Unable to create file ../user/dataaiueoandlc.xl./username.txt because No such file or directory in *******/new_account.php on line 82 2 3Warning: fopen(../user/dataaiueoandlc.xl./mail.txt): failed to open stream: No such file or directory in ******/new_account.php on line 98 4 5Warning: fwrite() expects parameter 1 to be resource, bool given in ******/new_account.php on line 101 6 7Warning: fclose() expects parameter 1 to be resource, bool given in ********/new_account.php on line 102 8 9Warning: Cannot modify header information - headers already sent by (output started at /home/users/2/pinoko.jp-blue-usuki-8825/web/test/File/login/new_account.php:12) in *********/new_account.php on line 115
PHP
1<?php 2session_start(); 3ini_set("error_reporting", 0); 4 5if (empty($_SESSION['username'])) { 6 $user_login_pas = "../user/guest/icon/icon.gif"; 7} else { 8 $user_login_pas = "../user/data/".$_SESSION['username']."/icon/icon.gif"; 9 header("location:../../index.php"); 10} 11?> 12 13<!DOCTYPE html> 14<html> 15<head> 16 <meta charset="utf-8"> 17 <meta name="viewport" content="width=device-width, initial-scale=1"> 18 <title>アカウント作成</title> 19 <link rel="stylesheet" type="text/css" href="../css/manu.css"> 20 <link rel="icon" type="image/png" href="../img/icon/icon.png"> 21 <nav> 22 <a href="../../index.php"> 23 <img style="position: absolute; top: 0px;left: 0px;" src="../img/home.jpg" title="home" alt="ホーム"> 24 </a> 25 26 <ul> 27 <li><a href="../site/news/news.php">ニュース</a></li> 28 <li><a href="../site/File_exchange/File_exchange.php">ファイル交換</a></li> 29 <li><a href="../site/Bulletin_board/Bulletin_board.php">掲示板</a></li> 30 <li><a href="../site/このサイトについて/site.php">このサイトについて</a></li> 31 <li><a href="./login_check.php">ログイン状況</a><li> 32 <li><a href=""><img style="width:25px;" src="<?php echo $user_login_pas; ?>"></a></li> 33 </ul> 34 </nav> 35 36 <h1>かさ上げ</h1> 37</head> 38 39<body> 40 <h2></h2> 41 <form enctype="" method="post"> 42 アカウントネーム<input type="text" name="accountname">(非公開) 43 <dir></dir> 44 メールアドレス:<?php echo $_SESSION['mail']; ?> 45 <dir></dir> 46 メールアドレスの再入力<input type="email" name="mail"> 47 <dir></dir> 48 ユーザーネーム<input type="text" name="username">(公開) 49 <dir></dir> 50 パスワード<input type="password" name="password"> 51 <dir></dir> 52 パスワード確認<input type="password" name="pas_check"> 53 <dir></dir> 54 確認コード:<?php echo $_SESSION['code']; ?> 55 <dir></dir> 56 <input type="submit" name="_submit" value="登録"> 57 <?php "<h3 style=color:red;>echo $msg</h3>" ?> 58 </form> 59</body> 60 61</html> 62 63<?php 64 65if (isset($_POST['_submit'])) { 66$name = $_POST['accountname']; 67$file = "../user/data/".$name; 68 69if (file_exists($file)) { 70 //存在した 71 $msg = "そのアカウントは使われています。"; 72 header("location:#error"); 73} else { 74 //存在しない 75 if ($_POST['password'] == $_POST['pas_check']) { 76 //pas 77 mkdir($file, 0777, true); 78 $data = $_POST['accountname']; 79 $file = fopen("../user/data/".$name."/username.txt", "w"); 80 81 touch("../user/data".$name."/username.txt"); 82 fwrite($file, $data); 83 fclose($file); 84 85//pas 86 87 $data = $_POST['password']; 88 $file = fopen("../user/data/".$name."/password.txt", "w"); 89 90 touch("../user/data/".$name."/password.txt"); 91 fwrite($file, $data); 92 fclose($file); 93 94//mail 95 96 $mail = $_POST['mail']; 97 $file = fopen("../user/data".$name."/mail.txt", "w"); 98 99 touch("../user/data/".$name."/mail.txt"); 100 fwrite($file, $mail); 101 fclose($file); 102 103//dhisp 104 105 $data = $_POST['username']; 106 $file = fopen("../user/data/".$name."/disp_name.txt", "w"); 107 108 touch("../user/data/".$name."/disp_name.txt"); 109 fwrite($file, $data); 110 fclose($file); 111 112// 113 114 header("Location:../../index.php"); 115 116 } else { 117 header("Location:./login.php"); 118 } 119 120} 121 122} 123?>
非効率ですが、いろいろ理由があって変数などは変更したくありません。
よろしくお願いいたします。
回答1件
あなたの回答
tips
プレビュー