function doesUserExist($userName, $password)
{
    require 'connect.php';
    $getUsers = 'select userName, password, firstName from users';
    $result = mysqli_query($connection, $getUsers);
    if ($result->num_rows > 0) {
        while ($user = mysqli_fetch_array($result)) {
            if ($user['userName'] == $userName && $user['password'] == $password) {
                //echo 'setting session userName variable as : ' . $userName;
                $_SESSION['userName'] = $userName;
                $_SESSION['firstName'] = $user['firstName'];
                $_SESSION['orderId'] = createOrderId();
                addOrderIdToDb($_SESSION['orderId'], $userName);
                return true;
            }
        }
    }
    return false;
}
        if ($allOrderedDishes->num_rows > 0) {
            while ($orderedDish = mysqli_fetch_array($allOrderedDishes)) {
                $dishId = $orderedDish['dishId'];
                $dishQuantity = $orderedDish['quantity'];
                $dishPrice = $orderedDish['price'];
                $insertIntoDishOrderHistory = "insert into dishOrderHistory\n\t\t\t\t\tvalues ('" . $orderId . "', " . $dishId . ", " . $dishQuantity . ", " . $dishPrice . ");";
                mysqli_query($connection, $insertIntoDishOrderHistory);
            }
        }
        $deleteDishOrders = "delete from dishOrders where orderId = '" . $orderId . "';";
        mysqli_query($connection, $deleteDishOrders);
        $deleteOrderId = "delete from orders where orderId = '" . $orderId . "';";
        mysqli_query($connection, $deleteOrderId);
        require 'functions.php';
        $_SESSION['orderId'] = createOrderId();
        addOrderIdToDb($_SESSION['orderId'], $_SESSION['userName']);
        $_SESSION['orderPlaced'] = true;
        header('Location: placeOrder.php') && exit;
    }
} else {
    $orderId = $_SESSION['orderId'];
    $fetchOrderedDishes = "select * from dishOrders where orderId = '" . $orderId . "';";
    $result = mysqli_query($connection, $fetchOrderedDishes);
    if ($result->num_rows > 0) {
        $totalPrice = 0.0;
        while ($orderedDish = mysqli_fetch_array($result)) {
            $totalPrice += $orderedDish['price'];
        }
        $_SESSION['totalPrice'] = $totalPrice;
        echo '<label id="totalPrice">Order Total : &#x20b9; ' . $totalPrice . '</label>';
    }