My issue seems to be that my info is not being saved into mysql database not only that but my Echos seem to not fire off as well in my IF statements I'm sure this is an easy fix right in front of me but I can't see what I'm doing wrong, any help please?
<?php
$firstname = "";
$lastname = "";
$email = "";
$password_1 = "";
$password_2 = "";
$errors = array();
$con = mysqli_connect('127.0.0.1','root','','registration');
if(mysqli_connect_errno())
{
echo "Error Occured while connnecting with the Database ".mysqli_connect_errno();
}
if(isset($_POST['register']))
{
$firstname = filter_var($_POST['firstname'], FILTER_SANITIZE_STRING);
$lastname = filter_var($_POST['lastname'], FILTER_SANITIZE_STRING);
$email = filter_var($_POST['email'], FILTER_SANITIZE_STRING);
$password_1 = filter_var($_POST['password_1'], FILTER_SANITIZE_STRING);
$password_2 = filter_var($_POST['password_2'], FILTER_SANITIZE_STRING);
if(empty($firstname))
{
array_push($errors,"First Name is required");
echo "wtf";
}
if(empty($lastname))
{
array_push($errors,"Last Name is required");
echo "wtf2";
}
if(empty($email))
{
array_push($errors,"Email is required");
echo "wtf3";
}
if(empty($password_1))
{
array_push($errors,"Password is required");
echo "wtf4";
}
if($password_1 != $password_2)
{
array_push($errors,"Password does not match");
echo "wtf5";
}
if(count($errors) == 0)
{
$password_1 = md5($password_1);
$sql = "INSERT INTO users('firstname','lastname','email','password') VALUES ('".$firstname."', '".$lastname."', '".$email."', '".$password_1."')";
mysqli_query($con, $sql);
}
}
?>