Move an object forward. But not up

I made a script that makes a camera move. And you control the rotation with your mouse. But the problem is. When looking up. And moving forward. You fly. I can’t figure out how to do this. Here’s my code:

using System.Collections;
using System.Collections.Generic;
using UnityEngine;

public class PlayerMoving : MonoBehaviour {
	float mouseInputY;
	float mouseInputX;
	Vector3 lookHere;
	public float WalkSpeed;
	public float sensitivity;
	public Transform Player;
	void Update () {
		if (Input.GetKey (KeyCode.LeftShift)) {
			WalkSpeed = 0.5f;
		}
		Cursor.lockState = CursorLockMode.Locked;
		mouseInputY = -Input.GetAxis ("Mouse Y") * sensitivity;
		mouseInputX = Input.GetAxis ("Mouse X") * sensitivity;
lookHere = new Vector3(mouseInputY, mouseInputX,0);
	Player.transform.Rotate(lookHere);
		float z = Player.transform.eulerAngles.z;
			Player.transform.Rotate(0, 0, -z);
		// Walking
		if (Input.GetKey ("w")) {
			Player.transform.Translate (Vector3.forward * WalkSpeed);
		}
		if (Input.GetKey ("s")) {
			Player.transform.Translate (Vector3.back * WalkSpeed);
		}
		WalkSpeed = 0.1f;
	}
}

Try Rigidbody.MovePosition. instead of translate.
And then in the inspector constrain the Y position.

Quick note- try to separate functionality in to different methods/classes with their own responsibilities. Additionally, unity documentation recommends that you handle physics type behaviors in FixedUpdate ()
and don’t forget to calculate by the time. Delta time where necessary.
documentation RigidBody.MovePosition. here :