Locking Rotation so Character can only turn on x axis

I’m working on a 3d Platformer, my current problem is when I walk forward the character rapidly spins in whatever direction im moving. how can i make it where he can only turn left and right?
Im using a box collider as the player’s collider.


using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PlayerController : MonoBehaviour {
	public float speed;
	private Rigidbody rb;

	void FixedUpdate ()
		rb = GetComponent<Rigidbody> ();
		//detects input and assigns movement variables to input values
		float moveHorizontal = Input.GetAxis ("Horizontal");
		float moveVertical = Input.GetAxis ("Vertical");
		//sets player force values base on movement variables above
		Vector3 movement = new Vector3 (moveHorizontal, 0.0f, moveVertical);
		//Applies force (movement) based off force values and multiplies by speed to determine total force
		rb.AddForce (movement * speed);

You can lock the eulerAngles like this:

Vector3 eulerAngles = transform.eulerAngles;
eulerAngles.z = 0f;//or whatever value and axis you want
transform.eulerAngles = eulerAngles;