Here is a question about two definitions. They are the following:

Definition 1. Let k be a fixed algebraically closed field. If X, Y are two affine varieties, a morphism \phi : X \rightarrow Y is a continuous map such that for every open set V \subseteq Y, and for every regular function f : V \rightarrow k, the function f \circ \phi : \phi^{-1}(V) \rightarrow k is regular.

Definition 2. A map f : X \rightarrow Y between two affine varieties X \subseteq \mathbb{A}^m and Y \subseteq \mathbb{A}^n is called a morphism if there exists n polynomials f_1, \ldots, f_n \in k[x_1, \ldots, x_m] such that f(x)=(f_1(x), \ldots, f_n(x)) for all x =(x_1, \ldots, x_m) \in X.

These are two definitions from different textbooks: Hartshorne, Algebraic Geometry, and Mumford, Algebraic Geometry I. Are these definitions equivalent or a similar restatement of them equivalent? If so, how do you prove that they are equivalent? I believe that they are equivalent but I do not see how to prove this. Thanks for your help.