logic error

hi every body when i run this code it isnot give any proplem but when i send"mohamad"by serial monitor it doesn't work
where the problem in my code
thanks

const int led=13;
String val="";
void setup() {pinMode(led,OUTPUT);
Serial.begin(9600);
  // put your setup code here, to run once:

}

void loop() {if(Serial.available()>0){int c=3;
  char e=Serial.read();
  val+=e;
  if(val=="mohamad"){
    Serial.print("yes you are write:");
    digitalWrite(led,HIGH);
    delay(400);
    digitalWrite(led,LOW);
    delay(400);
    c--;
    Serial.print(c);
    delay(10);
  val="";}
  else{Serial.print("wrong");
  delay(1000);
  }}val="";}

where the problem in my code

The first problem is the piss-poor layout. Put ONE statement per line.

The second is that you read one character, say an 'm', and add it to the String. The value in val is "m", which is not equal to "mohamad", so you empty the String. You will NEVER accumulate more than one character in the String the way you have written the code.

It is not a good idea to use the String (capital S) class on an Arduino as it can cause memory corruption in the small memory on an Arduino. Just use cstrings - char arrays terminated with 0.

Have a look at the examples in Serial Input Basics - simple reliable ways to receive data. There is also a parse example.

When using Cstrings you must use strcmp() to compare values rather than ==

...R