Facing to a issue with PHP crud opertaions

Hi I’m having a issue with crud operations. I building a small dashboard table project using PHP. But I’m facing to a issue when update the data.
I passed the element id using get operations to the update.php file and stored it in a variable then I tried update my table data using that table id. But when I insert new data and click the submit button id variable became undifined.

<?Php $pdo = new PDO('mysql:host=localhost;port=3306;dbname=jobs4u', 'root', ''); [quote="Isuru01, post:1, topic:509399, full:true"]

Hi I’m having a issue with crud operations. I building a small dashboard table project using PHP. But I’m facing to a issue when update the data.
I passed the element id using get operations to the update.php file and stored it in a variable then I tried update my table data using that table id. But when I insert new data and click the submit button id variable became undifined.

Blockquote

/part of my html form/

/*form content*/

/* */

<?Php

$pdo = new PDO('mysql:host=localhost;port=3306;dbname=jobs4u', 'root', '');
$pdo->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);

$id = $_GET['id'];


if (isset($_POST['submit'])) {

      $title = $_POST['title'];
      $location = $_POST['location'];
      $type = $_POST['type'];
      $industry = $_POST['industry'];
      $description = $_POST['description'];
      $closing_date = $_POST['closing_date'];

      '<pre>';
      echo  var_dump($title);/*return null8*/
      echo  var_dump($description);
      echo  var_dump($id);
      '</pre>';

      $pdo->exec("UPDATE vacancies SET title = '$title' WHERE job_id = '$id'");
}
?>

<!DOCTYPE html>
<html lang="en">
<head>
   content
</head>

<body>
   <form class="vacany-publish-form" action="vacancy_update.php" method="post">
         content
  </form>
</body

/table update button/

Edit

/part of my html form/

/*form content*/

/* */

/table update button/

>        <a href="vacancy_update.php?id=<?php echo $vacancy['job_id'] ?>" 
>          target=”_blank” class="btn btn-db-edit">Edit</a>

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.