Advertisement
Guest User

data.php

a guest
Jan 24th, 2020
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.34 KB | None | 0 0
  1. <?php
  2.  
  3.  
  4. // variables Mysql
  5. $dbhost = 'localhost';
  6. $dbname = 'catastro_medellin';
  7. $dbuser = 'wilmer';
  8. $dbpass = '945637';
  9.  
  10.  
  11. $mysqli = new mysqli($dbhost, $dbuser, $dbpass, $dbname);
  12.  
  13. $data = array('status' => false);
  14.  
  15. if(isset($_POST['submit'])){
  16.  
  17.    
  18.    
  19.     $cod_producto = $_POST['cod_producto'];
  20.     $descripcion = $_POST['descripcion'];
  21.     $detalles = $_POST['detalles'];
  22.     $precio = $_POST['precio'];
  23.     $otros = $_POST['otros'];
  24.     $card_front = $_POST['card_front'];
  25.     $card_back = $_POST['card_back'];
  26.  
  27.     $sql = "INSERT INTO `productos` (`productos_id`, `cod`, `descripcion`, `detalles`, `precio`, `otros`, `card_front`, `card_back`) VALUES (null, '".$cod_producto."', '".$descripcion."', '".$detalles."', '".$precio."', '".$otros."', '".$card_front."', '".$card_back."')";
  28.  
  29.     $result_insert = $mysqli->query($sql);
  30.  
  31.         $data['message'] = "Registro Exitoso";
  32.  
  33.    
  34.    
  35.  
  36.     $data['status'] = true;
  37.     /*
  38.     $target_file = basename($_FILES['file']['name']);
  39.     $file_type = pathinfo($target_file,PATHINFO_EXTENSION);
  40.    
  41.         $data['image'] = time() . '.'. $file_type;
  42.             if(move_uploaded_file($_FILES['file']['tmp_name'], $data['image'])){
  43.                 $data['status'] = true;
  44.             }else{
  45.                 $data['message'] = "Error on uploading image";
  46.             }*/
  47.    
  48. }
  49.  
  50. header('Access-Control-Allow-Origin: *');
  51. header('Content-type:application/json');
  52.  
  53. echo json_encode($data);
  54.  
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement