php - I am trying to update the data base table -


this update.php file fetching id username email , mobile number. here in same file trying update mysql table. press update button nothing happening. following update.php

    <?php      include ('config/config.php');       $id = $_get['id'];     if(isset($_get['id']))    {    $sql = "select username, email, mobile users id=".$id."";   $res= mysqli_query($conn, $sql);     $row=mysqli_fetch_array($res);    $username    = $row['username'];     $email       = $row['email'];    $mobile  = $row['mobile'];     }    if (isset($_post['update']))    {         $username = $_post['username'];         $email = $_post['email'];         $mobile = $_post['mobile'];          $upd = "update `users` set `username`='$username',`email`='$email',`mobile`='$mobile' id=$id";         $rest= mysqli_query($conn, $upd);          if ($rest) {             echo "data update successfully";         } else {             echo "failed update";         }         }         ?> 

and html file. using post method

        <form action="update.php" method="post">         <input type="hidden" name="id" id="id">         <input type="text"   name="username" id="username"       placeholder="username"          value="<?php echo $username;?>" ><br><br>         <input type="email"  name="email"      id="email"        placeholder="email"            value="<?php echo $email;?>"> <br><br>         <input type="mobile" name="mobilemobile "   id="mobile"  placeholder="mobile number"    value="<?php echo $mobile;?>" ><br><br>     </form>         <input type="submit" name="update" value="update" id="submit_update"> 

your form not have update parameter/element. below if block never successful.

if (isset($_post['update'])) 

edit: per edited code, submit button out of form element. value never submitted form. move submit button code inside form.

p.s. hope code testing purpose only, contains no input sanitization etc.


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -