I'm trying just to validate, on submitting the form that the username
and password
aren't empty.
Form:
<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();
}
?>
When I test, it says:
Parse error: syntax error, unexpected
T_VARIABLE
, expectingT_FUNCTION
on line :$entered = new Vuln;