PHP
1<!DOCTYPE html> 2<html lang="en" dir="ltr"> 3 4<head> 5 <meta charset="utf-8"> 6 <title>ろくまる農園</title> 7</head> 8 9<body> 10 スタッフ追加<br /> 11 <br /> 12 <form method="post" action="staff_add_check.php"> 13 スタッフ名を入力してください<br /> 14 <input type="text" name="name" width="200px"><br /> 15 パスワードを入力してください<br /> 16 <input type="password" name="pass" width="100px"><br /> 17 パスワードをもう一度入力してください<br /> 18 <input type="password" name="pass2" width="100px"><br /> 19 <input type="button" onclick="history.back()" value="戻る"> 20 <input type="submit" value="OK"> 21 </form> 22 23</body> 24 25</html> 26
PHP
1<!DOCTYPE html> 2<html lang="en" dir="ltr"> 3 4<head> 5 <meta charset="utf-8"> 6 <title>ろくまる農園</title> 7</head> 8 9<body> 10 11<?php 12 13$staff_name = $_POST['name']; 14$staff_pass = $_POST['pass']; 15$staff_pass2 = $_POST['pass2']; 16 17$staff_name = htmlspecialchars($staff_name, ENT_QUOTES, 'UTF-8'); 18$staff_pass = htmlspecialchars($staff_pass, ENT_QUOTES, 'UTF-8'); 19$staff_pass2 = htmlspecialchars($staff_pass2, ENT_QUOTES, 'UTF-8'); 20 21 22if ($staff_name == '') { 23 print 'スタッフ名が入力されていません。<br />'; 24} else { 25 print 'スタッフ名:'; 26 print $staff_name; 27 print '<br />'; 28} 29 30if ($staff_pass == '') { 31 echo 5; 32 print 'パスワードが入力されていません。<br />'; 33} 34 35if ($staff_pass != $staff_pass2) { 36 echo 6; 37 print 'パスワードが一致しません。<br />'; 38} 39 40if ($staff_name == '' || $staff_pass == '' || $staff_pass != $staff_pass2) { 41 echo 1; 42 print '<form>'; 43 print '<input type="button" onclick="history.back()" value="戻る">'; 44 print '</form>'; 45} else { 46 echo 2; 47 $staff_pass - md5($staff_pass); 48 print '<form method="post" action="staff_add_done.php">'; 49 print '<input type="hidden" name="name" value="'.$staff_name.'">'; 50 print '<input type="hidden" name="pass" value="'.$staff_pass.'">'; 51 print '<br />'; 52 print '<input type="button" onclick="history.back()" value="戻る">'; 53 print '<input type="submit" value="OK">'; 54 print '</form>'; 55} 56?> 57 58</body> 59 60</html>
PHPの参考書を動かしています。
上のページから下のページへと遷移する構成ですが、
入力ミスはないはずなのですが、何をしてもecho1のところに入ります。原因はなんでしょうか。
回答1件
あなたの回答
tips
プレビュー