can't make one press on button to turn something on and one press to turn off

i have this code, which that i tried thousands of codes and i didn't make this work...
i want to control relays from the internet (already working), and i want to add a push button (its not 4 leg push button, i have picture below) to turn on the function triggerPinNoClient that i made in this code.
i want that when i press the button long press it's will act like one press and doesn't make thousand presses, i think it called debounce. and in the meanwhile to receive orders from the web server...
how can i do it?

The code :

(to large for the forum)

Use a flag, and don't reset the flag until the input pin returns to the 'not pressed' state.

edit: most debounce demos don't worry about this auto-repeat feature, its actually useful in many cases, but not all.
But think of it as debouncing the 'Release' and NOT JUST the 'Press' as all the demos I seen for arduino do.

Have a look at the StateChangeDetection example in the IDE. From the comments in the program

Often, you don’t need to know the state of a digital input all the time,
but you just need to know when the input changes from one state to another.
For example, you want to know when a button goes from OFF to ON. This is called
state change detection, or edge detection.

This example shows how to detect when a button or button changes from off to on
and on to off.

That isn’t debouncing, it is edge detection. Use the example mentioned in the above post.

UKHeliBob:
Have a look at the StateChangeDetection example in the IDE. From the comments in the program

Often, you don't need to know the state of a digital input all the time,
but you just need to know when the input changes from one state to another.
For example, you want to know when a button goes from OFF to ON. This is called
state change detection, or edge detection.

This example shows how to detect when a button or button changes from off to on
and on to off.

i tired this and its always thinks that the button is HIGH even when i press him...

i tired this and its always thinks that the button is HIGH even when i press him...

Then your switch(es) are wired wrong. It's time you talked about how they are wired.

Some basic "toggle" test code. You probably use millis instead of the delay if desired.

//zoomkat LED button toggle test 11-08-2012

int button = 5; //button pin, connect to ground as button
int press = 0;
boolean toggle = true;

void setup()
{
  pinMode(13, OUTPUT); //LED on pin 13
  pinMode(button, INPUT); //arduino monitor pin state
  digitalWrite(5, HIGH); //enable pullups to make pin 5 high
}

void loop()
{
  press = digitalRead(button);
  if (press == LOW)
  {
    if(toggle)
    {
      digitalWrite(13, HIGH);   // set the LED on
      toggle = !toggle;
    }
    else
    {
      digitalWrite(13, LOW);    // set the LED off
      toggle = !toggle;
    }
  }
  delay(500);  //delay for debounce
}
const int buttonPin = 2;     // the number of the pushbutton pin
const int ledPin =  13;      // the number of the LED pin

byte oldPinState = HIGH;

void setup ()
  {
  pinMode (buttonPin, INPUT_PULLUP);  
  pinMode (ledPin, OUTPUT);
  }  // end of setup

void loop ()
  {
  byte pinState = digitalRead (buttonPin);
  if (pinState != oldPinState)
    {
    delay (10);  // debounce 
    if (pinState == LOW)
      digitalWrite (ledPin, !digitalRead (ledPin));  // toggle pin
    oldPinState = pinState;  // remember new state
    }  // end of if pin state change
  }  // end of loop