現在ツイッターもどき(自作SNS)を練習で作成中でございまして、
新規会員登録から、ログインの実装までは行けたのですが、
パスワードがハッシュ化できておりません。
今のコードを利用しつつ、下記を実装する効率的な方法を教えていただきたいと思い質問しました。
①まずパスワードのハッシュ化(新規会員登録側)
②ハッシュ化したパスワード(データベース)とログインフォームに入力したパスワードの整合
また、その他ここはこうした方がいいなどあれば、ぜひとも教えていただければと思います。
【新規会員登録】
ファイル名:index.php
<!-- 完了画面 --> <?php elseif( $page_flag === 2 ): ?><form method="post" action=""> <div class="element_wrap"> <label>お名前</label> <p><?=$name; ?></p> </div> <div class="element_wrap"> <label>ユーザーネーム</label> <p><?=$account; ?></p> </div> <div class="element_wrap"> <label>メールアドレス</label> <p><?=$email; ?></p> </div> <div class="element_wrap"> <label>パスワード</label> <p>*****************</p> </div> <input type="submit" name="btn_back" value="修正"> <input type="submit" name="btn_submit" value="送信"> <input type="hidden" name="your_name" value="<?=$name; ?>"> <input type="hidden" name="account" value="<?=$account; ?>"> <input type="hidden" name="email" value="<?=$email; ?>"> <input type="hidden" name="pass1" value="<?=$pass1; ?>"> </form> <br> <p><strong style="color:red;">注意!</strong><br> 修正を押されますとパスワードは<br> 消えてしまいますので<br> お手数ですが、再度ご入力をお願いします。</p>
<?php else: ?> <!-- 初期画面 ~エラー表示~ --><p><?=$name; ?> 様<br> ご登録完了しました。<br> 本登録が完了されましたので、<br> ログインしてください。</p> <div class="top_btn"> <a href ="http://localhost/mysns/login.php">ログイン画面へ</a> </div>
<!-- 初期画面 --><?php if(!empty($error)): ?> <ul class="error_list"> <?php foreach($error as $value): ?> <li><?=$value; ?></li> <?php endforeach; ?> </ul> <?php endif; ?>
<?php endif; ?> </body> </html><form method="post" action=""> <div class="element_wrap"> <label>お名前</label> <input type="text" name="your_name" value="<?php if(!empty($_POST['your_name'])){echo $_POST['your_name'];} ?>"> </div> <div class="element_wrap"> <label>ユーザーネーム</label> <input type="text" name="account" value="<?php if(!empty($_POST['account'])){echo $_POST['account'];} ?>"> </div> <div class="element_wrap"> <label>メールアドレス</label> <input type="text" name="email" value="<?php if(!empty($_POST['email'])){echo $_POST['email'];} ?>"> </div> <div class="element_wrap"> <label>パスワード</label> <input type="password" name="pass1" value="<?php if(!empty($_POST['pass1'])){echo $_POST['pass1'];} ?>"> </div> <div class="element_wrap"> <label>パスワード(確認)</label> <input type="password" name="pass2" value="<?php if(!empty($_POST['pass2'])){echo $_POST['pass2'];} ?>"> </div> <input type="submit" name="btn_confirm" value="入力内容を確認する"> </form>
【ログインフォーム】
ファイル名:login.php
</body> </html><!-- 初期画面 ~エラー表示~ --> <?php if(!empty($error)): ?> <ul class="error_list"> <?php foreach($error as $value): ?> <li><?=$value; ?></li> <?php endforeach; ?> </ul> <?php endif; ?> <form method="post" action=""> <div class="element_wrap"> <label>ユーザーネーム</label> <input type="text" name="account" value="<?php if(!empty($_POST['account'])){echo $_POST['account'];} ?>"> </div> <div class="element_wrap"> <label>パスワード</label> <input type="password" name="pass" value=""> </div> <input type="submit" name="btn_confirm" value="ログイン"> </form> <a href="index.php">新規登録のまだの方はこちら</a>
回答2件
あなたの回答
tips
プレビュー