Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2016
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1. <?php
  2.  
  3. $host = 'localhost';
  4. $user = 'root';
  5. $pass = '';
  6. $db = 'inversiones';
  7.  
  8. $conexion = mysqli_connect($host, $user, $pass) or die ('problemas con el servidor');
  9. mysqli_select_db($conexion, $db) or die ('problemas con la base de datos');
  10.  
  11. //recuperamos los valores del formulario
  12. $nombre = $_POST['nombre'];
  13. $telefono = $_POST['telefono'];
  14. $email = $_POST['email'];
  15. $direccion = $_POST['direccion'];
  16. $web = $_POST['web'];
  17. $proyecto = $_POST['proyecto'];
  18. $empresa = $_POST['empresa'];
  19. $ubicacion = $_POST['ubicacion'];
  20. $municipio = $_POST['municipio'];
  21. $origen = $_POST['origen'];
  22. $sector = $_POST['sector'];
  23. $inversion = $_POST['inversion'];
  24. $empleos = $_POST['empleos'];
  25. $dependencia = $_POST['dependencia'];
  26. $giro = $_POST['giro'];
  27. $fase = $_POST['fase'];
  28. $estatus = $_POST['estatus'];
  29. $semaforo = $_POST['semaforo'];
  30.  
  31. //
  32. $query1 = "INSERT INTO contacto
  33. (nombre, telefono, email, direccion, web) VALUES
  34. ('$nombre','$telefono','$email','$direccion','$web')";
  35. $resultado = mysqli_query($conexion, $query1);
  36. // Si dio error
  37. if ($resultado === false) {
  38. printf("Error: %sn", mysqli_error($conexion));
  39. die();
  40. }
  41. $var=mysql_insert_id();
  42.  
  43. //
  44. $query2 = "INSERT INTO empresas
  45. (proyecto, empresa, ubicacion, municipio, origen, sector, inversion, empleos, dependencia, giro, fase, id_contacto) VALUES
  46. ('$proyecto','$empresa','$ubicacion','$municipio','$origen','$sector','$inversion','$empleos','$dependencia','$giro','$fase', $var)";
  47. $resultado = mysqli_query($conexion, $query2);
  48. // Si dio error
  49. if ($resultado === false) {
  50. printf("Error: %sn", mysqli_error($conexion));
  51. die();
  52. }
  53.  
  54. header("Location: form_validation.php");
  55. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement