php - Update is not working for mysqli -
i trying information update in table. have spent hours , keep going in circles. think problem in query section toward end of code. appreciated. thanks.
<?php require "connect.php"; ?> <?php session_start(); if(isset($_session["id"])){ }else{ header('location:login.php'); } ?> <?php $user = $_session["id"]; $result = $con->query("select * bd id='$user'"); $row = $result->fetch_array(mysqli_both); $_session["firstname"] = $row['firstname']; $_session["lastname"] = $row['lastname']; $_session["email"] = $row['email']; $_session["username"] = $row['username']; $_session["password"] = $row['password']; ?> <?php if(isset($_post['update'])){ $updatefname = $_post['firstname']; $updatelname = $_post['lastname']; $updateemail = $_post['email']; $updateuname = $_post['username']; $updatepassword = $_post['password']; $sql = $con->query("update bd set firstname = '{$updatefname}', lastname = '{$updatelname}', email = '{$updateemail}', username = '{$updateuname}', password = '{$updatepassword}' id= $user"); header('location: update.php'); } ?>
you have used post method wrongly. should use post method $_post[''] not $_post[''].
if(isset($_post['update'])){ $updatefname = $_post['firstname']; $updatelname = $_post['lastname']; $updateemail = $_post['email']; $updateuname = $_post['username']; $updatepassword = $_post['password']; $sql = $con->query(" update bd set firstname = '$updatefname', lastname = '$updatelname', email = '$updateemail', username = '$updateuname', password = '$updatepassword' id= '$user'" ); header('location: update.php'); }
Comments
Post a Comment