Hello,
I’m trying to workout an inheritance issue in PHP but its not working as I want, I’m receiving the message: Fatal error: Class ‘ValidateUserInput’ not found in C:\xampp\htdocs\InheritanceTesting\authenticationClass.php on line 2.
- the files are in the folder.
- I check a few online tutorial and I still cant seem to pinpoint the error message I’m getting.
Any help you can provide would be greatly appreciated.
index.php
<?php
require_once(‘authenticationClass.php’);
require_once(‘validateClass.php’);
$classReturn = new Authentication();
if(isset($_POST['btl_logIn']) && $_POST['btl_logIn'] == 'Log In'){
$test1 = $classReturn->UserAuthentication($_POST['txt_userEmail']);
if($test1){
echo 'found';
}
else{
echo 'Not found';
}
}
?>
<br><br>Inheritance testing<br><br>
<form method="POST" action="" name="loginForm">
<div id="loginContainer" style="border: 1px solid green; float: middle; width:600px;" >
<input type="text" name="txt_userEmail" placeholder="Email" />
<input type="submit" name="btl_logIn" value="Log In">
</div>
</form>
authenticationClass.php
<?php
class Authentication extends ValidateUserInput {
public function UserAuthentication($userEmail){
if($this->senitizeEmailField($userEmail)){
return TRUE;
}
else{
return false;
}
}
}
?>
validateClass.php
<?php
class ValidateUserInput{
public function senitizeEmailField($userEmail){
if (isset($userEmail)) {
$pattern = '/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$/';
if (!preg_match($pattern, $userEmail)) {
return FALSE;
}
else {
return TRUE;
}
}
else{
return FALSE;
}
}
}
?>