title: email validation in php(no javascript)
body: <p>Greetings for the day,</p>
  
  <p>I am new to php and my company gave me a task of registration form,
  i want to know how to  validate email address using php(not with JavaScript)
  like there will must a one . and @ sign
  i have done t using JavaScript but TL said that it must be using PHP.
  My Html code is given below 
  can any one help??</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;&lt;title&gt;Form validation&lt;/title&gt;
      &lt;script type="text/javascript"&gt;
  /*function validateEmail() {
      var emailText = document.getElementById('email').value;
      var pattern = /^[a-zA-Z0-9\-_]+(\.[a-zA-Z0-9\-_]+)*@[a-z0-9]+(\-[a-z0-9]+)*(\.[a-z0-9]+(\-[a-z0-9]+)*)*\.[a-z]{2,4}$/;
      if (pattern.test(emailText)) {
          return true;
      } else {
          alert('Bad email address: ' + emailText);
          return false;
      }
  }
  
  window.onload = function() {
      document.getElementById('email_form').onsubmit = validateEmail;
  }
  */
  &lt;/script&gt;
  
  
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;form action="&lt;?php echo base_url();?&gt;index.php/validation_control/insert_to_db"  method="post" id="email_form" onsumbit="return myFunction()"&gt;
  &lt;table align="center" border="2"&gt;
  &lt;tr&gt;&lt;td&gt;Username :- &lt;td&gt;&lt;input type="text" name='uname'/&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;First Name :- &lt;td&gt;&lt;input type="text" name='fname'/&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Last Name :- &lt;td&gt;&lt;input type="text" name='lname'/&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Email :- &lt;td&gt;&lt;input type="text" name='email' /&gt;&lt;?php //echo $emailErr;?&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Password :-&lt;td&gt;&lt;input type="password" name='pass' id='pass'/&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Confirm Password :-&lt;td&gt;&lt;input type="password" name='cnfpass' id='cnfpass'/&gt;&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td&gt;Status :-&lt;td&gt;&lt;input type="radio" name="status" value="active" /&gt;Active&lt;input type="radio" name="status" value="deactive" /&gt;Deactive&lt;input type="radio" name="status" value="delete" /&gt;Delete&lt;/td&gt;&lt;/td&gt;&lt;/tr&gt;
  &lt;tr&gt;&lt;td align="center" colspan="2"&gt;&lt;input type="submit" name="sbmt" id="sbmt" value="Submit" onclick="Javscript:validateEmail"/&gt;&lt;/td&gt;&lt;/tr&gt;
  
  
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>