PHP again guys.... still in the dark i guess
i tried running this code and i know that i created an array of $errors but i don't know why am getting this error: Notice: Undefined variable: errors in C:\xampp\htdocs\server.php on line 50 Here is the code: <? session_start(); $username = ""; $email = ""; $errors = array(); //connecting to the database $db = mysqli_connect('localhost', 'root', '', 'registration'); include('errors.php'); //if the register button is clicked if (isset($_POST['register'])) { $username =mysql_real_escape_string($_POST['username']); $email =mysql_real_escape_string($_POST['email']); $password_1 =mysql_real_escape_string($_POST['password_1']); $password_2 =mysql_real_escape_string($_POST['password_2']); //ensure that form fields are filled properly if ($username == "") { array_push($errors, "username is requied"); // add error to errors array } if ($email == "") { array_push($errors, "Email is requied"); // add error to errors array } if ($password_1 == "") { arry_push($errors, "Password is requied"); // add error to errors array } if ($password_1 != $password_2) { array_push($errors, "The two passwords does not match"); // add error to errors array } // if ther are no errors, save user too database if (count($errors) == 0) { $password = md5($password_1); //encrypt password before storing in database (security) $sql = "INSERT INTO users (username, email,password) VALUES ('$username', '$email', '$password')"; mysqli_query($db, $sql); $_SESSION['username'] = $username; $_SESSION['success'] = "You are now logged in"; header('location: index.php'); // redirects to homepage } } ?> <?php if (count($errors) > 0): ?> <div class="error"> <?php foreach ($errors as $error): ?> <p><?php echo $error; ?></p> <?php endforeach ?> </div> <?php endif ?> i really could use your help please