Collision bug in a 2D platfrom game.

Hi,
I’m new to java, and game programming and I’m starting my first big project which is a 2D platform puzzle game.
This is my player movement code


		
		if (speedX > 0 && centerX <= 400){
			centerX += speedX;
		}
		
		if (speedX < 0 && centerX >= 400){
			centerX += speedX;
		}
		
		if (speedX > 0 && centerX >= 400){
			bg1.setSpeedX(-MOVESPEED);
			bg2.setSpeedX(-MOVESPEED);
		}
		
		if (speedX < 0 && centerX <= 400){
			bg1.setSpeedX(MOVESPEED);
			bg2.setSpeedX(MOVESPEED);
		}
		
		if (speedX == 0){
			bg1.setSpeedX(0);
			bg2.setSpeedX(0);
		}
		
		if(movingRight == true && movingLeft == true ){
			bg1.setSpeedX(0);
			bg2.setSpeedX(0);
		}

		// Handles Jumping
		if (jumped == true) {
			speedY += 1;


		}

		// Prevents going beyond X coordinate of 0
		if (centerX + speedX <= 60) {
			centerX = 61;
		}
		rect.setRect(centerX - 47, centerY - 65, 32, 87);
		
		centerY += speedY;
	}

	public void moveRight() {
				speedX = MOVESPEED;		
	
	}

	public void moveLeft() {
			speedX = -MOVESPEED;
	}

	public void stopRight() {
		movingRight = false;
		stop();
	}

	public void stopLeft() {
		movingLeft = false;
		stop();
	}

	private void stop() {
		if (movingRight == false && movingLeft == false) {
			speedX = 0;
		}
		if (movingRight == false && movingLeft == true) {
			moveLeft();
		}

		if (movingRight == true && movingLeft == false) {
			moveRight();
		}
}

	

	public void jump() {
		if (jumped == false) {
			speedY = JUMPSPEED;
			jumped = true;
		}

	}


and this is the collision code


    public void checkCollision(Rectangle rect){
    	if (rect.intersects(r)){
    		if(Player.movingRight){
    		Player.centerX = tileX + 11;
    		Player.speedX =0;
    		}
    		
    		if(Player.movingLeft){
    		Player.centerX = tileX + 89;
    		Player.speedX = 0;
    		}
    		
    		if(Player.speedY > 0){
    			Player.centerY = tileY - 25;
    			Player.speedY = 0;
    			Player.jumped = false;
    		}
    	}
 
    }
    


There are two problems.The first one is that if I press one of the movement keys when landing the character “teleports” to the right or left.
I know this happens because I programmed it that if the character intersects with the ground while movingRight or movingLeft are true he moves right or left.(I made it this way so the horizonal collision will work) and I cant think of any other way to do it or how to fix it.

The second problem is that if the character moves of a platfrom he does not fall down.
I tryed to fix it by adding to the collision method


else{
speedY += 1;
}

But it made the character disappear for some reason.

Thanks a lot!

By the way, sorry for my english it is not my native language.