<?php
if(isset($_POST['submit']))
{
$email=$_POST['email'];
$password=$_POST['password'];
$username=$_POST['username'];
$error="";
if(filter_var($email,FILTER_VALIDATE_EMAIL))
{
$error="Please enter a valid email";
}
if($email!==null && $email!=="" && $password!==null && $password!=="" && $username!==null && $username!=="")
{
$error="Please enter all the fields first";
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<title>User Login System</title>
</head>
<body>
<div id="Register-form">
<h1>Registration form</h1>
<form id="register-form" method="post" action="" >
<label>Email</label>
<input type="email" id="email" name="email" />
<label>Password</label>
<input type="password" id="password" name="password" />
<label>UserName</label>
<input type="text" id="username" name="username" />
<input type="submit" id="submit" name="submit" value="Register" />
<span><?php echo $error;?></span>
</form>
</div>
</body>
</html>
After running this code this error is coming in the validation error variable i have initalized error variable but it is saying undefined error variable
Notice: Undefined variable: error in C:\xampp\htdocs\UserLogin\index.php on line 39
This is the error which is showing up can you please tell me the solution of this problem.Thanks in advance.
Basically the problem is with $error variable which is there in the script please tell me if i remove it or can i modify so that my problem is solved.