Advertisement
Guest User

Untitled

a guest
Sep 22nd, 2017
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.69 KB | None | 0 0
  1. <?php
  2.     header('Content-type: application/json');
  3.  
  4.     $user = 'root';
  5.     $password = 'Knight93';
  6.     $dbh = new PDO('mysql:host=localhost;dbname=tdpx', $user, $password);
  7.     $dbh->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
  8.  
  9.     $sth = $dbh->prepare("UPDATE part SET productID=:productid, name=:description, weight=:weight WHERE id=:id");
  10.    
  11.    
  12.     if($sth->execute(array('productid' => $_POST['productid'], 'description' => $_POST['description'], 'weight' => $_POST['weight'], 'id' => $_POST['id']))){
  13.         echo "{'success':true}";
  14.     }else{
  15.         $error = print_r($sth->errorInfo());
  16.         echo "{'success':false, 'error: " .$error."}";
  17.     }
  18.  
  19.     exit;
  20. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement