title: Allow only capital and small letters
body: <p>I would like to accept only small and capital letters from the user.</p>
  
  <p>I tried the below code, it echoes the invalid character message but doesn't work. I mean it doesn't check. It just displays the message. Any help?</p>
  
  <pre><code>&lt;form action="" method="post"&gt;
  &lt;input type="text" name="fname"&gt;
  &lt;input type="submit" value="Send" name="submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p><strong>Update:</strong> this is what I have to check and insert the name to database. if numbers found in the name reject the name by displaying the error message else if the name contains only letters insert it into database. That's all I want to acheive.</p>
  
  <pre><code>&lt;?php
  if ( isset( $_POST['submit'] ) ) { 
  $fname = $_POST["fname"];
  
  if(!preg_match ('/^([a-zA-Z]+)$/', $fname)){
  echo "Invalid characters";
  }
  
  if (empty($fname)) {
  echo  '&lt;span&gt; First name is required&lt;/span&gt;';
  }
  
  else{
  $mysqli = new mysqli("localhost", "root", "", "test");
  $stmt = $mysqli-&gt;prepare("INSERT INTO test (firstname) VALUES (?)");
  
  $stmt-&gt;bind_param("s", $fname);
  $stmt-&gt;execute();
  
  $stmt-&gt;close();
  
  $mysqli-&gt;close();
  
  
  }
  }
  ?&gt;
  </code></pre>