How to loop a program with a button

Use a flag variable, which is a global boolean.

bool pressed = false;

void loop() {

  if (buttonstate == HIGH) {
    pressed = true;
  }

  if ((sensor == HIGH) && (pressed == true)) {
   // do what ever
  }
}

At some point you will need to make "pressed" false again. Also, for robust code, you need "button state detection." A good tutorial is here: https://www.arduino.cc/en/Tutorial/StateChangeDetection