php - Need help on updating a data on a database table using facebox -


good day of you. title says need facebox when updating data(s).

here's code button show facebox

echo '         td>             <a  rel="facebox" href="../admin/c_status.php?id='.$row["userid"].'">edit</a>         </td>     '; 

and here's code inside facebox

 <?php include("../db/dbcon.php"); //$id = $_get['id']; //echo $id; ?>  status <form method="post">     <select name="selactive" id ="selactive">         <option value="active">active</option>         <option value="in-active">in-active</option>         <option value="graduate">graduate</option>     </select>     <br>     <br>      <button class="btn btn-success btn-block btn-large" name="savechangebutton" id ="savechangebutton">save changes</button> </form>  <?php     if(isset($_post['savechangebutton'])){         $id = $_get['id'];         $status = $_post['selactive'];          $cstatus = $conn->prepare("update useraccount set status = :status userid = :userid");         $cstatus->bindparam(':status', $status);         $cstatus->bindparam(':userid', $id);         $cstatus->execute();     } ?> 

the problem encounter data won't update via clicking edit button when edit via address bar "http://localhost/ict/admin/c_status.php". work.

you can make input type hidden , make value equal $_get['id']

   <form method="post">         <select name="selactive" id ="selactive">             <option value="active">active</option>             <option value="in-active">in-active</option>             <option value="graduate">graduate</option>         </select>          <input type="hidden" name="userid" value="<?php echo $_get['id'];?>">         <br>         <br>          <button class="btn btn-success btn-block btn-large" name="savechangebutton" id ="savechangebutton">save changes</button>     </form> 

then transfer php code update useraccount below or above link.when used facebox, form have opened pop became part of file therefore logical transfer php code update accounts here since didn't specify action attribute of form above.

   echo '<td>             <a  rel="facebox" href="../admin/c_status.php?id='.$row["userid"].'">edit</a>         </td>';     include("../db/dbcon.php");     if(isset($_post['savechangebutton'])){         $id = $_post['userid'];         $status = $_post['selactive'];          $cstatus = $conn->prepare("update useraccount set status = :status userid = :userid");         $cstatus->bindparam(':status', $status);         $cstatus->bindparam(':userid', $id);         $cstatus->execute();     } 

hope helps


Comments

Popular posts from this blog

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -