Advertisement
Guest User

Untitled

a guest
Sep 23rd, 2017
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. <script>
  2. function saveData(){
  3. var dni = $('#cli_dni').val();
  4. var nombres = $('#cli_nom').val();
  5. var apellidos = $('#cli_ape').val();
  6. var direccion = $('#cli_dir').val();
  7. var celular = $('#cli_cel').val();
  8. $.ajax({
  9. type: "POST",
  10. url: "conexion.php?p=add",
  11. data: "cli_dni="+dni+"&cli_nom="+nombres+"&cli_ape="+apellidos+"&cli_dir="+direccion+"&cli_cel="+celular,
  12. });
  13. }
  14. </script>
  15.  
  16. <?php
  17. $db = new PDO('mysql:host=localhost;dbname=systemfarma','root','');
  18. $page = isset($_GET['p'])?$_GET['p']:'';
  19. if($page=='add'){
  20. $dni = $_POST['cli_dni'];
  21. $nombres = $_POST['cli_nom'];
  22. $apellidos = $_POST['cli_ape'];
  23. $direccion = $_POST['cli_dir'];
  24. $celular = $_POST['cli_cel'];
  25. $stmt = $db->prepare("insert into clientes values('',?,?,?,?)");
  26. $stmt->$bindParam(1,$dni);
  27. $stmt->$bindParam(2,$nombres);
  28. $stmt->$bindParam(3,$apellidos);
  29. $stmt->$bindParam(4,$direccion);
  30. $stmt->$bindParam(5,$celular);
  31. $stmt->execute();
  32. }else if($page=='edit'){
  33.  
  34. }else if($page=='del'){
  35.  
  36. }else{
  37.  
  38. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement