Button switch with two buttons and two leds

Hallo, I tried a long time, but didn't find a solution. I want to use 2 buttons, each button controlls one led and change the actual status from High to low and Low to High with a push.

My actual code controls alway both leds no matter which button i push. Pls help me thx.

int inPin = 2; // the number of the input pin
int outPin = 13;
int inPin2 = 3; // the number of the input pin
int outPin2 = 12; // the number of the output pin
// the number of the output pin

int state = HIGH; // the current state of the output pin
int reading; // the current reading from the input pin
int previous = LOW; // the previous reading from the input pin

// the follow variables are long's because the time, measured in miliseconds,
// will quickly become a bigger number than can be stored in an int.
long time = 0; // the last time the output pin was toggled
long debounce = 200; // the debounce time, increase if the output flickers

void setup()
{
pinMode(inPin, INPUT);
pinMode(outPin, OUTPUT);
pinMode(inPin2, INPUT);
pinMode(outPin2, OUTPUT);
}

void loop()
{
reading = digitalRead(inPin);

// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;

time = millis();
}

digitalWrite(outPin2, state);

reading = digitalRead(inPin2);

// if the input just went from LOW and HIGH and we've waited long enough
// to ignore any noise on the circuit, toggle the output pin and remember
// the time
if (reading == HIGH && previous == LOW && millis() - time > debounce) {
if (state == HIGH)
state = LOW;
else
state = HIGH;

time = millis();
}

digitalWrite(outPin2, state);

previous = reading;
}

It is interesting that your post title refers to TWO switches and TWO LEDs, but your code has ONE variable to keep track of the previous state of the TWO switches.

The words all in caps need to match...

 digitalWrite(outPin2, state);

Then later

 digitalWrite(outPin2, state);

As a wild guess you got one button/LED working then copied the code and forgot to edit it