problem with player script

i did a script for player’s movement where my player has to move and jump according to the inputs, only when he is in the ground or on any surface and not in air. i wrote the script in such a way that i introduced a variable to check whether my player is in collision with ground and if so he will move. i dont know where in my script i got stuck up with. please tell me where i got stuck up with.

public class player_move : MonoBehaviour {
	
	public float speed = 10;
	public float jumpVelocity = 10;
	bool grounded = false;

	// Use this for initialization
	void Start () {
	
	}
	
	// Update is called once per frame
	void Update () {
		
		if(grounded)
		{		
		  float amtToMove = Input.GetAxisRaw("Horizontal") * speed * Time.deltaTime;		
		  transform.Translate(-Vector3.right * amtToMove);
		
		  if(Input.GetKeyUp("space"))
		   {
			 rigidbody.velocity = new Vector3(0, 10, 0);
		   }
			grounded = false;
		}
		
	 }
	
	void OnCollisionEnter(Collision other)
	{
		if(other.gameObject.name == "platform")
		{
			grounded = true;
			//Debug.Log ("iam hit");
		}
	}
}

You put your grounded = false line in the wrong place. Try this:

public class player_move : MonoBehaviour {
 
    public float speed = 10;
    public float jumpVelocity = 10;
    bool grounded = false;
 
    // Use this for initialization
    void Start () {
 
    }
 
    // Update is called once per frame
    void Update () {
 
       if(grounded)
       {     
         float amtToMove = Input.GetAxisRaw("Horizontal") * speed * Time.deltaTime;   
         transform.Translate(-Vector3.right * amtToMove);
 
         if(Input.GetKeyUp("space"))
          {
          rigidbody.velocity = new Vector3(0, 10, 0);
          grounded = false;
          }
       }
 
     }
 
    void OnCollisionEnter(Collision other)
    {
       if(other.gameObject.name == "platform")
       {
         grounded = true;

       }
    }