このログイン フォームを投稿するためのデータベースをまだ作成していません... 118 行目に構文エラー、予期しない '<' というエラーが表示されます。このコードは、無効な文字をチェックし、リストされた無効な文字が見つかりました。この投稿のコードが正しい形式になっていないことをお詫び申し上げます。
<!DOCTYPE html>
<html>
<?php
function checkCharacters($input_string)
{
$char_array = str_split($input_string);
$string_length = strlen($input_string);
for($i = 0; $i < $string_length; $i++)
{
if(ord($char_array[$i]) == 39) //ASCII value of ' is 39
return false;
if(ord($char_array[$i]) == 34) //ASCII value of '' is 34
return false;
if(ord($char_array[$i]) == 59) //ASCII value of ; is 59
return false;
if(ord($char_array[$i]) == 60) //ASCII value of < is 60
return false;
if(ord($char_array[$i]) == 62) //ASCII value of > is 62
return false;
if(ord($char_array[$i]) == 35) //ASCII value of # is 35
return false;
if(ord($char_array[$i]) == 37) //ASCII value of % is 37
return false;
if(ord($char_array[$i]) == 36) //ASCII value of $ is 36
return false;
if(ord($char_array[$i]) == 38) //ASCII value of % is 38
return false;
if(ord($char_array[$i]) == 43) //ASCII value of + is 43
return false;
if(ord($char_array[$i]) == 58) //ASCII value of : is 58
return false;
if(ord($char_array[$i]) == 40) //ASCII value of ( is 40
return false;
if(ord($char_array[$i]) == 41) //ASCII value of ) is 41
return false;
if(ord($char_array[$i]) == 42) //ASCII value of * is 42
return false;
if(ord($char_array[$i]) == 33) //ASCII value of ! is 33
return false;
if(ord($char_array[$i]) == 45) //ASCII value of - is 45
return false;
if(ord($char_array[$i]) == 47) //ASCII value of / is 47
return false;
if(ord($char_array[$i]) == 60) //ASCII value of < is 60
return false;
if(ord($char_array[$i]) == 61) //ASCII value of = is 61
return false;
if(ord($char_array[$i]) == 62) //ASCII value of > is 62
return false;
if(ord($char_array[$i]) == 63) //ASCII value of ? is 63
return false;
if(ord($char_array[$i]) == 91) //ASCII value of [ is 91
return false;
if(ord($char_array[$i]) == 92) //ASCII value of \ is 92
return false;
if(ord($char_array[$i]) == 58) //ASCII value of : is 58
return false;
if(ord($char_array[$i]) == 93) //ASCII value of ending bracket is 93
return false;
if(ord($char_array[$i]) == 94) //ASCII value of ^ is 94
return false;
if(ord($char_array[$i]) == 95) //ASCII value of _ is 95
return false;
if(ord($char_array[$i]) == 96) //ASCII value of ` is 96
return false;
if(ord($char_array[$i]) == 123) //ASCII value of { is 58
return false;
if(ord($char_array[$i]) == 124) //ASCII value of | is 124
return false;
if(ord($char_array[$i]) == 125) //ASCII value of } is 125
return false;
if(ord($char_array[$i]) == 126) //ASCII value of ~ is 126
return false;
} //end for
return true;
} //end checkCharacters function
<form id="login" action="login.php" method="post" accept-charset="UTF-8">
<fieldset >
<legend>Welcome to Scrabble! Login below. </legend>
<input type="hidden" name="submitted" id="submitted" value="1"/>
<label for="username" >UserName*:</label>
<input type="text" name="username" id="username" maxlength="10" />
<label for="password" >Password*:</label>
<input type="password" name="password" id="password" maxlength="10" minlength="8"/>
<input type="submit" name="Submit" value="Submit" />
</form>
</fieldset>
$name = $POST['Name'];
$name_valid = checkCharacters($name);
$password = $_POST['Password'];
$password_valid = checkCharacters($password);
if(($name_valid == false) || ($password_valid == false))
echo "You have entered an invalid username/password combination. Please try again.<br /><br />";
</html>
?>