title: for update code in same page need ajax or else?
body: <p>when i press on <em>edit</em> link on <strong>detail.php</strong> it will show me <strong>data.php</strong> page with data filled in form... now if i want to edit something then press edit <strong>button</strong> it would be update.. code of data.php is given as below</p>
  
  <pre><code>&lt;?php if(isset($_GET['name']) &amp;&amp; !empty($_GET['name'])):?&gt;
  &lt;script&gt;
  window.onload=function()
  {
  document.getElementById("sbmt").style.visibility="hidden";
  
  };              
  function editform()
  {
  </code></pre>
  
  <p><strong>i need code at this place</strong> _what should it be?? i guess i need ajax. when i press edit button it would be edit record i tried below something like below bt for that i need value name=???  how can i get that value _</p>
  
  <pre><code>&lt;?php
  $con=mysqli_connect("localhost","root","","my_db");
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
     // mysqli_query($con,"UPDATE user_detail SET     name=,address=,gender=,hoby=,country=,place=,
      //WHERE name='$_GET['name']'");
  
  mysqli_close($con);
  ?&gt;
  };                          
  &lt;/script&gt;
  &lt;?php
  $con=mysqli_connect("localhost","root","","my_db");
  // Check connection
  if (mysqli_connect_errno())
    {
    echo "Failed to connect to MySQL: " . mysqli_connect_error();
    }
  $p= $_GET['name'];
  //echo "$p";
  $result = mysqli_query($con,"SELECT * FROM user_detail where name ='$p' ");
  $data =mysqli_fetch_array($result);
  mysqli_close($con);
  ?&gt;
  &lt;?php else:?&gt;
  &lt;script&gt;
  window.onload=function()
  {
  document.getElementById("edit").style.visibility="hidden";
  
  };
  &lt;/script&gt;
  
      &lt;?php $data =array();?&gt;
  &lt;?php endif;?&gt;
  &lt;!DOCTYPE html&gt;
  &lt;?php 
  session_start();
  if (!isset($_SESSION['txt_user'])) {
  header('Location: Login.php');
  }
  ?&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;title&gt; Form with Validation &lt;/title&gt;
  
  &lt;script language="JavaScript"&gt;
  var flag=0;
  var file_selected = false;
  var file_selected1 = false;
  
  function validform()
  {
      var x=document.forms["form1"]["tname"].value;//Name
      var y=document.forms["form1"]["address"].value;//Address
  
      if (x==null || x=="")
      {   
          flag = 1;
  
          document.getElementById('tn').value="Please! Enter name ";
          //alert("Please Enter Name:");
          //return false;
      }
      else
      {
          flag=0;
      }
      if (y==null || y==" ")
      {   
          flag=flag+1;
          document.getElementById('ta').innerHTML="Please! Enter address ";
  
          //alert("Please Enter Address");
          //return false;
      }
      else
      {
          flag=0;
      }
      if ((form1.gender[0].checked == false) &amp;&amp; (form1.gender[1].checked == false))
      {
          flag +=1;
          document.getElementById('gne').innerHTML="Please! Select gender ";  
          //alert("Pleae Select Gender");
          //return false;
      }
      else
      {
          flag =0;
          document.getElementById('gne').innerHTML="";
      }
      if (form1.hobby.checked == false &amp;&amp; form1.hobby.checked == false &amp;&amp; form1.hobby.checked == false) 
      {
          flag +=1;
          document.getElementById('hbe').innerHTML="Please! Select hobby ";
          //alert ('Please!!!, Select any hobby!');
          //return false;
      } 
      else
      {
          flag =0;
          document.getElementById('hbe').innerHTML="";
      }
      var psel=document.getElementById('fp'); //Favourite place
      var valid = false;
      for(var i = 0; i &lt; psel.options.length; i++) {
          if(psel.options[i].selected) {
              valid = true;
  
              break;
          }
      }
      if(valid==false)
      {
          flag +=1;
          document.getElementById('fp_error').innerHTML="Please! Select Any Favourite Place ";
          //return false;
          //  alert("Please! Select Any Favourite Place ");
      }
      else
      {
              flag =0;
              document.getElementById('fp_error').innerHTML="";
      }
      if(!file_selected)
      {
          flag +=1;
          document.getElementById('f_pic').innerHTML="Please! Select Any Picture ";
          //alert('Please Select any Picture');
          //return false;
      }
      else
      {
          flag =0;
          document.getElementById('f_pic').innerHTML="";
      }
      if(!file_selected1)
      {
          flag +=1;
          document.getElementById('f_doc').innerHTML="Please! Select Document";
          //alert('Please Select any Document');
              //return false;
      }
      else
      {
          flag =0;
      }
  
      if(flag ==0)
      {
          document.getElementById('data_form').action = "Data_con.php";  
          document.getElementById('data_form').submit();
  
      }
      else
      {
          return true;
      }
      return false;
  }
  function Logout()
  {
  document.getElementById('data_form').action = "Logout.php";
  }
  
  &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt; 
  &lt;!--onsubmit="return validform()"--&gt;
  &lt;form id="data_form" name="form1" method="post" enctype="multipart/form-data" action=""&gt;
  
  &lt;table align="center" border="2"&gt;
  
  &lt;tr&gt;
  &lt;td&gt;Name:&lt;/td&gt;
  &lt;td&gt;&lt;input id="tn" type="text" name="tname" &lt;?php if($data['name']):?&gt;value="&lt;?php echo $data['name'];?&gt;" &lt;?php endif;?&gt;&gt;&lt;/td&gt;
  
  &lt;!--&lt;td id="tne"&gt;&lt;/td&gt;--&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;Address:&lt;/td&gt;
  
  &lt;td&gt;&lt;textarea id= "ta" rows="3" cols="16" name="address" &gt; 
  &lt;?php echo $data['address'];?&gt;
  &lt;/textarea&gt; &lt;/td&gt;
  &lt;!--&lt;td id="tae"&gt;&lt;/td&gt;--&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;Gender:&lt;/td&gt;
  
  
  &lt;?php 
      $x=$data['gender'];
  ?&gt;
  &lt;td&gt; &lt;input type="radio" id="gn" name="gender" value="male" &lt;?php if($x=='male'):?&gt; checked&lt;?php endif;?&gt; &gt;  Male
  &lt;input type="radio" id="gn" name="gender" value="female" &lt;?php if($x=='female'):?&gt; checked&lt;?php endif;?&gt; &gt; Female
  &lt;/td&gt;
  &lt;td id="gne"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  
  
  
  &lt;tr&gt;
  &lt;td&gt;Hobby:&lt;/td&gt;
  &lt;?php
  $y=$data['hoby'];
  ?&gt;
  &lt;td&gt;
  &lt;input type="checkbox" name="hobby" value="hockey" &lt;?php if($y=='hockey'):?&gt; checked='checked';&lt;?php endif;?&gt;&gt; Hockey
  &lt;input type="checkbox" name="hobby" value="reading" &lt;?php if($y=='reading'):?&gt; checked='checked';&lt;?php endif;?&gt;&gt; Reading&lt;br&gt;
  &lt;input type="checkbox" name="hobby" value="traveling" &lt;?php if($y=='traveling'):?&gt; checked='checked';&lt;?php endif;?&gt;&gt; Traveling
  &lt;br&gt;
  &lt;/td&gt;
  &lt;td id="hbe"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;Country: &lt;/td&gt;
  &lt;?php
  $z=$data['country'];
  ?&gt;
  &lt;td&gt;
  &lt;select name="helo" id="hl"&gt;
  &lt;option value="germany"&lt;?php if($z=='germany'):?&gt; selected&lt;?php endif;?&gt; &gt;Germany &lt;/option&gt;
  &lt;option value="india" &lt;?php if($z=='india'):?&gt; selected &lt;?php endif;?&gt; &gt;India &lt;/option&gt;
  &lt;option value="japan" &lt;?php if($z=='japan'):?&gt; selected&lt;?php endif;?&gt; &gt;Japan &lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;td id="hle"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;Favourite Place:&lt;/td&gt;
  &lt;?php
  $w  =$data['place'];
  ?&gt;
  &lt;td&gt;
  &lt;select id="fp"  name="place" multiple="multiple"&gt;
  &lt;option value="ahmedabad" &lt;?php if($w=='ahmedabad'):?&gt; selected&lt;?php endif;?&gt; &gt;Ahmedabad&lt;/option&gt;
  &lt;option value="nadiad" &lt;?php if($w=='nadiad'):?&gt; selected&lt;?php endif;?&gt; &gt;Nadiad&lt;/option&gt;
  &lt;option value="anand" &lt;?php if($w=='anand'):?&gt; selected&lt;?php endif;?&gt; &gt;Anand&lt;/option&gt;
  &lt;option value="vadodara" &lt;?php if($w=='vadodara'):?&gt; selected&lt;?php endif;?&gt; &gt;Vadodara&lt;/option&gt;
  &lt;option value="surat" &lt;?php if($w=='surat'):?&gt; selected&lt;?php endif;?&gt; &gt;Surat&lt;/option&gt;
  &lt;/select&gt;
  &lt;/td&gt;
  &lt;td id="fp_error"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td&gt;Photo:&lt;/td&gt;
  &lt;td&gt;&lt;input type="file" onchange="file_selected=true;" name="pic"  &gt;&lt;/td&gt;
  &lt;td id="f_pic"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  
  &lt;tr&gt;
  &lt;td&gt;Resume:&lt;/td&gt;
  &lt;td&gt;&lt;input type="file" onchange="file_selected1=true;" name="doc" &gt;&lt;/td&gt;
  &lt;td id="f_doc"&gt;&lt;/td&gt;
  &lt;/tr&gt;
  
  &lt;tr&gt;
  &lt;td colspan="2"&gt;&lt;center&gt;
      &lt;input type="Submit" id="edit" value="edit" Name="Edit" onclick="editform();"&gt; 
      &lt;input type="button" id="sbmt" value="Submit" Name="Submit" onclick="validform();"&gt;
      &lt;input type="submit" value="Logout" Name="Submit" onclick="Logout();"&gt;
  &lt;center&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;/table&gt;
  &lt;/form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Thanks friend...</p>