Consider the Lagrangian for a simple harmonic oscillator
\begin{equation}
L (x,\dot{x}) = \frac{1}{2}m\dot{x}^2 - \frac{1}{2}kx^2
\end{equation}
Obviously we have
\begin{align}
\frac{\partial L}{\partial x} & = -kx\\
\frac{\partial L}{\partial \dot{x}} & = m\dot{x}\\
\frac{d}{dt} \left(\frac{\partial L}{\partial \dot{x}}\right) & = m\ddot{x}
\end{align}
So this satisfies the Euler-Lagrange in that we know a $F = ma$ and therefore the force of a spring should follow this law as well, giving us
\begin{align}
\frac{d}{dt} \left(\frac{\partial L}{\partial \dot{x}}\right) -\frac{\partial L}{\partial x} & =0 \\
m\ddot{x} + kx &= 0
\end{align}
Now let's do the Hamiltonian version. Here's where I'm having a problem. We obtain the Hamiltonian via the Legendre transformation and get
\begin{equation}
H(x,p) = \frac{1}{2}\frac{p^2}{m} + \frac{1}{2}kx^2
\end{equation}
Now, according to what I understand, the equations of motion should be
\begin{align}
-\frac{\partial H}{\partial x} & = -kx = \dot{p}\\
\frac{\partial H}{\partial p} & = \frac{p}{m} = \dot{x}
\end{align}
But I don't see what this tells me about the relationship between Newton's law and Hooke's law. For the Lagrangian, when I plug in the relevant information, I get a relationship that explicitly shows for the action
\begin{equation}
S[x] = \int_a^bL(t,x,\dot{x})dt
\end{equation}
that it satisfies the EL equation as a necessary condition for $S[x]$ to have an extremum for the given function $x(t)$.
My Question:
How do Hamilton's equations do this? When I look at the "equations of motion" for the Hamiltonian, I don't see how they tell me anything about the action. But they should! That's what their purpose is, just like their Lagrangian analogs do.
The only way I see to do it is to do something like \begin{align} \frac{d}{dt}\left(m\frac{\partial H}{\partial p}\right) & = m\frac{d}{dt}\dot{x}\\ &=m\ddot{x}\\ \end{align} and then organize them something like \begin{align} \frac{d}{dt} \left(m\frac{\partial H}{\partial p}\right) + \frac{\partial H}{\partial x} & =0 \\ m\ddot{x} + kx &= 0 \end{align} But I've never seen anyone do this in the introductory books, so I feel like I must be misunderstanding what the Hamiltonian signifies relative to the action.