Edit Directory

my code is below, i want to edit fields in mysql and not add as a new record. help please

<?php
session_start();
error_reporting(0);
include('include/dbconnection.php');
if (strlen($_SESSION['pdaid']==0)) {
  header('location:logout.php');
  } else{

if(isset($_POST['submit']))
  {
    $fullname=$_POST['fullname'];
    $profession=$_POST['profession'];
    $email=$_POST['email'];
    $mobilenumber=$_POST['mobilenumber'];
    $address=$_POST['address'];
    $account_n=$_POST['account_n'];
    $sort=$_POST['sort'];
    $rent=$_POST['rent'];
    $bonus=$_POST['bonus'];
    $notes=$_POST['notes'];
    $bywho=$_POST['bywho'];
    $city=$_POST['city'];
    $admsta=1;
     
    $query=mysqli_query($con, "insert into tbldirectory (FullName,Profession,Email,MobileNumber,Address,account_n,sort,rent,bonus,notes,bywho,City,Status) value('$fullname','$profession','$email','$mobilenumber','$address','$account_n','$sort','$rent','$bonus','$notes','$bywho','$city','$admsta')");
    if ($query) {
    $msg="Client Details Updated Successfully";
  }
  else
    {
      $msg="Something Went Wrong. Please try again";
    }

  
}
  ?>

this didn’t really help me :frowning:

Since this is the same php code as in your previous thread (w only a different error_reporting value), why are you starting new threads for the same problem?

It is not the same problem I am wanting to know how to update a directory rather that create a new one.

*Same code, different problem *

You aren’t updating a directory, you are updating a record in the database. Simple update statement is all that is needed. I was posting how to do an upsert, which curtails issues if a record does not presently exist.

i am relatively new to all this, could you please show me how to update a record? every time i try to update a record, it just makes a duplicate with the changes made as a new record

Look up, sql update in mysql

Sponsor our Newsletter | Privacy Policy | Terms of Service