Ver Mensaje Individual
  #3 (permalink)  
Antiguo 25/09/2013, 20:23
Avatar de fegm_4
fegm_4
 
Fecha de Ingreso: febrero-2013
Mensajes: 114
Antigüedad: 12 años
Puntos: 8
Respuesta: Error archivo php no puede conectarse

Yo haría lo siguiente

Archivo registro.html
Código HTML:
Ver original
  1. <!doctype html>
  2. <title>Codigo para guardar</title>
  3. </head>
  4. <h1><strong>Formulario de registro</strong></h1>
  5. <form action="procesar.php" method="post" name="datos">
  6. <br>Nombre:<input name="nombre" type="text" id="nombre"></br>
  7. <br>Primer Apellido:<input type="text" name="papellido"></br>
  8. <br>Segundo Apellido:<input type="text" name="sapellido"></br>
  9. <input type="submit" name="ok" id="ok" value="Aceptar"/>
  10. </form>
  11. </body>
  12. </html>

Archivo procesar.php
Código PHP:
Ver original
  1. <?php
  2. if(isset($_POST)){
  3. $nombre = $_POST['nombre'];
  4. $apellido = $_POST['papellido'];
  5. $apellido2 = $_POST['sapellido'];
  6. $userDB = MiNombreDeUsuarioDeLaBDD;
  7. $passDB = MiContraseñaDeLaBDD;
  8. $myDB = NombreDeLaBDD;
  9. if(!is_null($nombre)){
  10. mysql_connect ('localhost', $userDB, $passDB);
  11. $resultado = mysql_query("INSERT INTO prueba (nombre, primerapellido, segundoapellido) VALUES ('$nombre', '$apellido', '$apellido2')") or die(mysql_error());
  12. if($resultado){
  13. echo 'Se han insertado los datos';
  14. }
  15. }
  16. }
  17. ?>
__________________
--
Aqui fegm_4