<?php
	include($_SERVER['DOCUMENT_ROOT'] ."/_ps2020/config/connect.php");

    //THis page has been created to validate if a certain username already exists!!
	$email = $_POST["Email"];
	// echo "no code is found";

    $email_exists = false;

	$result = $conn->query("SELECT * FROM user_account");
		
		if($result) {
			while ( $row = $result->fetch_assoc() ){
                // echo 'no code is found';
                if($row["email"] == $email){
                    $email_exists = true;
                    echo "Email is already registered!";
                }else{
                    //User name is not taken so far
                    $email_exists = false;
                }		
			}
        }
        if(!$email_exists){
            echo "Email is Unique!";
        }

	$conn->close();
?>