title: update query not working and change fields to 0
body: <p>i have this form code.</p>
  
  <pre><code>&lt;form action="save_profile.php" method="post"&gt;
            &lt;table&gt;
              &lt;tr&gt;&lt;td&gt;First Name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="fname" value="&lt;?php echo $fname;?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;Last Name:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="lname" value="&lt;?php echo $lname;?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;Mail ID:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="mail" value="&lt;?php echo $mail;?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;Contact NO:&lt;/td&gt;&lt;td&gt;&lt;input type="text" name="contact" value="&lt;?php echo $contact;?&gt;"&gt;&lt;/td&gt;&lt;/tr&gt;
              &lt;tr&gt;&lt;td&gt;&lt;/td&gt;&lt;td&gt;&lt;input type="submit" name="submit" value="Save Profile"&gt;&lt;/td&gt;&lt;/tr&gt;
            &lt;/table&gt;
            &lt;/form&gt;
  </code></pre>
  
  <p>and my save_profile.php file has this code.</p>
  
  <pre><code>&lt;?php
  session_start();
  require('config.php');
  function is_valid_fname($fname,$lname,$contact)
  {
   if (empty($fname)) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;First Name is required.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   }
   if ( !preg_match ("/^[a-zA-Z\s]+$/",$fname)) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;First Name Only Contain Letters.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   } 
   if (strlen($fname)&gt;20) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;First Name must be less than 20 Letters.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   }
   if (empty($lname)) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Last Name is required.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   }
   if ( !preg_match ("/^[a-zA-Z\s]+$/",$lname)) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Last Name Only Contain Letters.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   } 
   if (strlen($lname)&gt;20) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Last Name must be less than 20 Letters.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   }
   if (empty($contact)) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Contact is required.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   }
   if ( !preg_match ("/^[0-9\s]+$/",$contact)) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Contact Only Contain Numbers.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   }
   if (strlen($contact)&gt;15) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Contact must be less than 20 Digits.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   } 
   else{
    return true;
   }
  }
  function is_valid_email($mail)
  {
   if (empty($mail)) {
       ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Email is required.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
       return false;
   } else {
       $email = test_input($mail);
       // check if e-mail address is well-formed
       if (!filter_var($mail, FILTER_VALIDATE_EMAIL)) {
         ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Invalid Email Format.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php 
         return false;
   } 
   // now check if the mail is already registered
   $slquery = "SELECT 1 FROM user_tbl WHERE user_mail = '".$mail."'";
   $selectresult = mysql_query($slquery);
   if(mysql_num_rows($selectresult)&gt;1) {
     ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;This Email Is Already Exits.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
     return false;
   }
   // now returns the true- means you can proceed with this mail
   return true;
  }
  }
  if (isset($_POST['submit'])){
  $fname = $_POST['fname'];
  $lname = $_POST['lname'];
  $mail = $_POST['mail'];
  $contact = $_POST['contact'];
  function test_input($data) {
  $data = trim($data);
  $data = stripslashes($data);
  $data = htmlspecialchars($data);
  return $data;
  }
  if (is_valid_email($mail) &amp;&amp; is_valid_fname($fname,$lname,$contact))
  {
      $query="UPDATE user_tbl SET user_fname='".$fname."' AND user_lname='".$lname."' AND user_mail='".$mail."' AND user_contact='".$contact."' WHERE user_id='".$_SESSION['uid']."'";
       $result = mysql_query($query);
       if ($result) {
           header('location:profile.php');
       }
  }
  else{
        ?&gt;
       &lt;center&gt;&lt;strong&gt;&lt;font color="red"&gt;Error Updating User.&lt;/font&gt;&lt;/strong&gt;&lt;/center&gt;
       &lt;?php
      }
  }
  ?&gt;
  </code></pre>
  
  <p>my problem is after displaying data in form when i change form data and when i submit form it will always update my user_fname=0...when i change other field then my other fields remain same and set user_fname=0.please help me...</p>