Suppose $p \in A \cap B$. To show connectedness of $A \cup B$, write $A \cup B=U \cup V$, where $U$ and $V$ are open disjoint subsets of $A \cup B$. It suffices to show $U$ or $V$ is empty...
So where is $p$? It must be in $U$ or in $V$, say $p\in U$ for definiteness; by symmetry it doesn't matter (or rename letters in the following proof).
Then $A = (A \cap U) \cup (B \cap V)$ (simple set theory). Also, as $U \cap A$ is open in $A$ and $V \cap A$ is open in $A$ too (subspace topolgoy wrt a subspace topology is again the subspace topology). And these sets are still disjoint. And we know $A$ is connected, so both sets cannot be non-empty at the same time, and we already know $p \in U \cap A \neq \emptyset$, so $V \cap A = \emptyset$.
The exact same argument (mutatis mutandis) can be made for $B$ (also connected) as well so $V \cap B=\emptyset$.
But then $$V = V \cap (A \cup B) = (V \cap A) \cup (V \cap B) = \emptyset \cup \emptyset = \emptyset$$
and we are done: $A \cup B$ is connected.