title: Changing and saving mysql user data within a view Table which displays a user's data
body: <p>I have a table which displays user-data fetched from a mysql table.i want to make it editable right within the cells of this table. I have used php to show data inside "text" type input fields as shown in the code.</p>
  
  <p>In order to resubmit the changed data, I have wrapped the table row within a form, but the issue is that the form data is not resubmitted. I want to make the user change his details and submit it using "save user data" button which is neither sending data for updation-on-click and nor working as submit button. I tried using onsubmit also. Please help.</p>
  
  <pre><code>        &lt;!DOCTYPE html&gt;
  &lt;html&gt;
    &lt;head&gt;
      &lt;title&gt;SAS User Info
      &lt;/title&gt;
      &lt;script&gt;
        function chgform(){
          var frm = document.createElement("FORM");
          var v0 = document.getElementById("ser").value;
          var v1 = document.getElementById("name").value;
          var v2 = document.getElementById("typo").value;
          var v3 = document.getElementById("email").value;
          frm.ser.value = v0;
          frm.name.value = v1;
          frm.typo.value = v2;
          frm.email.value = v3;
          frm.action='editu.php';
          frm.submit();
  
        };
      &lt;/script&gt;
      &lt;?php
  require('connect.php');
  if ($_SERVER['REQUEST_METHOD'] === 'POST') {
  $user = $_POST['userlist'];
  $queryU = "SELECT ser, username, user_type, email FROM `user` WHERE username = '$user'";
  $listU = $connection-&gt;query($queryU);
  if ($listU-&gt;num_rows &gt; 0){
  while($rowu = $listU-&gt;fetch_assoc()) {
  $s = $rowu['ser'] ;
  $u = $rowu['username'] ;
  $t = $rowu['user_type'] ;
  $e = $rowu['email'] ;
  $tt = NULL;
  if($t=="Administrator"){$tt = "checked"; $z=NULL;}
  else {$z = "checked";}
  }
  }
  else {
  $s = $t = $u = $e = 'Nil';
  }
  }
  ?&gt;
      &lt;style&gt;
        body{
          margin: 0;
          padding: 0;
          background: transparent;
          font-family: Arial;
          font-size: 22px;
          color: #000;
        }
        input[type=email], input[type=text]{
          background: transparent;
          border: 1px solid rgba(255,255,255,0.6);
          border-radius: 2px;
          //color: #fff;
          font-family: 'Exo', sans-serif;
          font-size: 22px;
          font-weight: 400;
          padding: 4px;
          -webkit-placeholder-color: white;
        }
        .bkg{
          position: absolute;
          top: -20px;
          left: -20px;
          right: -40px;
          bottom: -40px;
          width: auto;
          background-image: url("main.jpg");
          height: 800px;
          background-size: cover;
          -webkit-filter: blur(2px);
          z-index: 0;
        }
        ::-webkit-input-placeholder{
          color: rgba(255,255,255,.8);
          font-family: Helvetica;
        }
        .grad{
          position: absolute;
          top: -20px;
          left: -20px;
          right: -40px;
          bottom: -40px;
          width: auto;
          height: 800px;
          background: -webkit-gradient(linear, left top, left bottom, color-stop(20%,rgba(0,0,0,0)), color-stop(100%,rgba(10,10,10,0.65)));
          z-index: 1;
          opacity: 0.7;
        }
        .header{
          position: fixed;
          top: calc(35% - 35px);
          left: calc(32% - 255px);
          z-index: 2;
        }
        .nav{
          position: fixed;
          top: calc(40% - 75px);
          left: calc(25% - 255px);
          height: 250px;
          width: 270px;
          padding: 10px;
          z-index: 1;
          background-color:rgba(75, 75, 75, 0.5);
        }
        .vuser{
          position: absolute;
          top: calc(40% - 75px);
          left: calc(38% - 90px);
          height: 250px;
          width: 926px;
          padding: 10px;
          z-index: 2;
          background-color:rgba(75, 75, 75, 0.5);
        }
        .header div{
          float: left;
          height:auto;
          color: #fff;
          font-family: 'Exo', sans-serif;
          font-size: 45px;
          font-weight: 300;
        }
        input[type=button]{
          width: 260px;
          height: 35px;
          background: #fff;
          border: 1px solid #fff;
          cursor: pointer;
          border-radius: 2px;
          color: #a18d6c;
          font-family: 'Exo', sans-serif;
          font-size: 16px;
          font-weight: 700 ;
          padding: 6px;
          margin-top: 10px;
        }
        input[type=button]:hover, 
        input[type=submit]:hover, input[type=reset]:hover{
          opacity: 0.8;
        }
        input[type=button]:active{
          opacity: 0.6;
        }
        input[type=password]:focus,input[type=text]:focus,
        input[type=email]:focus
        {
          border: 15px solid rgba(255,255,255,0.9);
        }
        }
        ::-moz-input-placeholder{
          color: rgba(255,0,0,1);
        }
        .style2 {
          font-weight: bold}
        .style6 {
          font-weight: bold}
        .style8 {
          font-weight: bold}
        .style10 {
          font-weight: bold}
      &lt;/style&gt;
    &lt;/head&gt;
    &lt;body&gt;
      &lt;div class="bkg"&gt;
      &lt;/div&gt;
      &lt;div class="grad"&gt;
      &lt;/div&gt;
      &lt;div class="header"&gt;
        &lt;div&gt;SAS
        &lt;/div&gt;
      &lt;/div&gt;
      &lt;br&gt;
      &lt;div class="nav" id="nav"&gt;
        &lt;br&gt;
        &lt;br&gt;
        &lt;br&gt;
        &lt;br&gt;
        &lt;input type="button" id="bkp"  onclick="window.location='panel.php'" value="Back to Control Panel"&gt;&amp;nbsp;
        &lt;input type="button" id="bkm"  onclick="window.location='index.html'" value="Back to Main"&gt;
        &lt;input type="button" id="sub" type="submit" onsubmit="chgform()"  value="Save User Data"&gt;
      &lt;/div&gt;
      &lt;div class="vuser" id="vuser"&gt;
        &lt;table id="tab" width="928" style="opacity: 0.9;" height="250" border="1" bordercolor="#666666" bgcolor="#FFFFFF"&gt;
          &lt;tr align="undefined" valign="top" bgcolor="#2693ff"&gt;
            &lt;th height="62" colspan="4" align="center" valign="middle" class="style2" scope="col"&gt; 
              &lt;p style="margin-top: 0; margin-bottom: 0;;"&gt;&amp;nbsp;
              &lt;/p&gt;
              &lt;p style="margin-top: 0; margin-bottom: 0;;"&gt;User Registeration Data
              &lt;/p&gt;
            &lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr valign="top"&gt;
            &lt;th width="35" height="62" align="center" valign="middle" class="style26" scope="col"&gt;
              &lt;strong&gt;Ser
              &lt;/strong&gt;
            &lt;/th&gt;
            &lt;th width="200" align="center" valign="middle" class="style26 style6" scope="col"&gt;
              &lt;p style="margin-top: 0; margin-bottom: 0;"&gt;Username
              &lt;/p&gt;
            &lt;/th&gt;
            &lt;th width="200" align="center" valign="middle" class="style26 style8" scope="col"&gt;
              &lt;p style="margin-top: 0; margin-bottom: 0;"&gt;User Type
              &lt;/p&gt;
            &lt;/th&gt;
            &lt;th width="365" align="center" valign="middle" class="style26 style10" scope="col"&gt;
              &lt;p style="margin-top: 0; margin-bottom: 0;"&gt;Email 
              &lt;/p&gt;
            &lt;/th&gt;
          &lt;/tr&gt;
          &lt;tr valign="top"&gt;
            &lt;form name="data" id="data" method="GET" action="editu.php" &gt;
              &lt;th height="59" align="center" valign="middle" id = "ser" name="ser" class="style26" scope="row"&gt;
                &lt;?php echo $s ?&gt;
              &lt;/th&gt;
              &lt;th align="center" valign="middle" class="style26" scope="row"&gt; 
                &lt;div align="center"&gt;
                  &lt;input type="text" style="margin-top: 0; margin-bottom: 0;" name="name" id="name" maxlength="15" size="15" pattern="[a-z,A-Z,0-9]{5,15}" value="&lt;?php echo $u ?&gt;" required&gt;
                  &lt;/input&gt;
              &lt;/div&gt;
          &lt;/th&gt;
        &lt;th align="left" valign="left" class="style26"&gt;
          &lt;input type="radio" style="margin-top: 0; margin-bottom: 0;" name="typo" id="typo" value="&lt;?php echo $t ?&gt;" 
                 &lt;?php echo $tt; ?&gt;  required&gt;Administrator
        &lt;/radio&gt;
      &lt;br&gt;
      &lt;input type="radio" style="margin-top: 0; margin-bottom: 0;" name="typo" id="typo" value="&lt;?php echo $t ?&gt;" 
             &lt;?php echo $z; ?&gt;" required&gt;User
      &lt;/radio&gt;
    &lt;/th&gt;
  &lt;th align="center" valign="middle" class="style26"&gt;
    &lt;div align="center"&gt;
      &lt;input style="margin-top: 0; margin-bottom: 0;" type="email" name="email" maxlength="30" size="30" placeholder="Enter your email" value="&lt;?php echo $e ?&gt;" required&gt;
      &lt;/input&gt;
  &lt;/div&gt;
  &lt;/th&gt;
  &lt;/tr&gt;
  &lt;/form&gt;
  &lt;/table&gt;
  &lt;/div&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>My editu.php is here>></p>
  
  <pre><code>&lt;?php 
  require('connect.php');
  if ($_SERVER['REQUEST_METHOD'] === 'GET') {
  $ser = $_GET['ser'];
  $usr = $_GET['name'];
  $typ = $_GET['typo'];
  $eml = $_GET['email'];
  $chg = "UPDATE `user` SET `username` = '$usr' , `usertype` = '$typ' ,         
  `email` = '$eml' WHERE `ser` = '$ser' ";
  $upd = $connection-&gt;query($chg);
  header( "refresh:1; url=viewuser.php" );
  }
  ?&gt;
  </code></pre>