username
とpassword
が空でないフォームを送信する際に、検証しようとしています。
フォーム:
<form action="usercheck.php" method="post">
User: <input type="text" name="username" maxlength="10" />
Pass: <input type="password" name="password" maxlength="10" />
<input type="submit" value="Submit" />
</form>
usercheck.php
<?php
class Vuln{
public $username = $_POST['username'];
public $password = $_POST['password'];
public function ShowErrors(){
if($this->username == '' || $this->password == ''){
return 'username or password field blank';
}
else{
echo stripslashes('we\'re good');
}
}
$entered = new Vuln;
echo $entered->ShowErrors();
}
?>
テストすると、次のように表示されます。
解析エラー:構文エラー、予期しない、次の行
T_VARIABLE
を期待T_FUNCTION
:$entered = new Vuln;