There are several things wrong with your code but the major one is that you can't do all the recording in the button function. That is an interrupt service routine which must deal with an event quickly and then return.
The button function should only set a flag (ideally an unsigned character which must also be declared volatile). The loop function then continuously tests this flag and when it is on it then executes the code that you currently have in the button function AND it also turns the flag off again.
If this code is meant to delay it definitely should not be in an interrupt routine but:
while (i < 300000) {
i++;
}
it may not delay at all. The compiler is probably smart enough to figure out that the result of that loop is to set i to 300000 and will replace the loop with i = 300000;
Even if the compiler leaves it as it is, how long is this delay supposed to last? You'd be better off using delay or millis.
There are obviously other problems too but fix these up first.
Pete