I am creating a registration form for a project, nothing secure or advanced, i am still fairly new to php etc.
I insert the data needed to into a login table and a customer tbl, the data inserts fine. But i cant get the code to check that its worked and fire off a an email and display a message to the user.
I have tried using a value retrieved from the database which would only be there is the user registered successfuly.
if($userID != null)
            {
                $msg1 = "Thank You! you are now registered, please check your email for a verification link to verify your new account! ";
                $col1 = "green";
                //require_once "Mail.php";
                require_once "inc/email.php";
            }
I have also tried this
if($query)
            {
                $msg1 = "Thank You! you are now registered, please check your email for a verification link to verify your new account! ";
                $col1 = "green";
                //require_once "Mail.php";
                require_once "inc/email.php";
        }
Thanks,
Edit - Here is all the code,
    <?php
    include ("inc/mysql.php");  
    error_reporting(0);
    $msg = "";
    $col = 'green';
    function test_input($data){
            $data = trim($data);
            $data = stripslashes($data);
            $data = htmlspecialchars($data);
        return $data;
    }
    // define variables and set to empty values
    $name = $email = $chkemail = $password = $chkpassword =$address = $towncity = $postcode = "";
//Required field validation
if ($_SERVER["REQUEST_METHOD"] == "POST") {
           if (empty($_POST["name"])) {
                $msg = "Name is required";
                $col = 'red';
          } else {
                $name = test_input($_POST["name"]);
          }
          if (empty($_POST["email"])) {
                $msg = "Email is required";
                $col = 'red';
          } else {
                $email = test_input($_POST["email"]);
          }
          if (empty($_POST["chkemail"])) {
                $msg = "Please confirm your email address";
                $col = 'red';
          } else {
                $chkemail = test_input($_POST["chkemail"]);
          }
          if (empty($_POST["password"])){
                $msg = "Please enter a password";
                $col = 'red';
          } 
          if (empty($_POST["chkpassword"])){
                $msg = "Please confirm your password ";
                $col = 'red';
          } else{
                $chkpassword = test_input($_POST["chkpassword"]);
                if(($_POST["password"]) != $chkpassword) {
                    $msg = "Please check your password is correct";
                    $col = 'red';
                } else{
                    $password = test_input($_POST["password"]);
                }
          }
          if (empty($_POST["address"])) {
                $msg = "Please enter the first line of your address";
                $col = 'red';
          } else {
            $address = test_input($_POST["address"]);
          }
          if (empty($_POST["towncity"])) {
                $msg = "Please enter the first line of your Town or City";
                $col = 'red';
          } else {
            $towncity= test_input($_POST["towncity"]);
          }
          if (empty($_POST["postcode"])) {
                $msg = "Please enter your postcode";
                $col = 'red';
          } else {
            $postcode = test_input($_POST["postcode"]);
            $customerVeri = "N";
            if($customerVeri == "N"){
            $name = mysqli_real_escape_string($db, $name);
            $email = mysqli_real_escape_string($db, $email);
            $password = mysqli_real_escape_string($db, $password);
            $password = md5($password.substr($email,0,3));
            $chkpassword = md5($password.substr($email,0,3));
            $verifyLink = md5(substr($name,0,3).substr($email,0,3));
            $sql="SELECT customerEmail FROM customer_tbl WHERE customerEmail='$email'";
            $result=mysqli_query($db,$sql);
            $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
            if(mysqli_num_rows($result) == 1)
            {   
                $msg1 = "Sorry...This email already exists, please enter another or login...";
                $col1 = "red";
            }
            else
            {
            $query = mysqli_query($db, "INSERT INTO login_tbl (customerEmail, customerPassword)VALUES ('$email', '$password')");
            $sql="SELECT userID FROM login_tbl WHERE customerEmail='$email'";
            $result=mysqli_query($db,$sql);
            $row=mysqli_fetch_array($result,MYSQLI_ASSOC);
            $userID = $row['userID'];
            $query2 = mysqli_query($db, "INSERT INTO customer_tbl (customerName, userID, customerEmail, customerPassword, customerAddress, customerTowncity, customerPostcode, customerVerified, customerVerifiedlink)VALUES ('$name', '$userID', '$email', '$password','$address','$towncity','$postcode','$customerVeri','$verifyLink')");
            echo("Error description: " . mysqli_error($db));
        }
          }
          }
}
    if($userID != null)
            {
                $msg1 = "Thank You! you are now registered, please check your email for a verification link to verify your new account! ";
                $col1 = "green";
                //require_once "Mail.php";
                require_once "inc/email.php";
            }
echo '<div style="color:'.$col.'">';
echo $msg;
echo '</div>';
echo '<div style="color:'.$col1.'">';
echo $msg1;
echo '</div>';
?>
 
    