Ver Mensaje Individual
  #8 (permalink)  
Antiguo 17/11/2009, 12:04
Avatar de dcreate
dcreate
 
Fecha de Ingreso: octubre-2009
Ubicación: Veracruz
Mensajes: 536
Antigüedad: 14 años, 7 meses
Puntos: 22
Respuesta: Necesito ayuda insert

un ejemplo basico:

index.php

Código php:
Ver original
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
  5. <title>Documento sin t&iacute;tulo</title>
  6. </head>
  7.  
  8. <body>
  9. <form id="form1" name="form1" method="post" action="procesar.php">
  10.   <label>Dato:
  11.   <input type="text" name="dato" />
  12.   </label>
  13.   <p>
  14.     <label>
  15.     <input type="submit" name="Submit" value="Enviar" />
  16.     </label>
  17.   </p>
  18. </form>
  19. </body>
  20. </html>

procesar.php
Código php:
Ver original
  1. <?php
  2. include "conexion.php";
  3. $dato=$_POST['dato'];
  4. conectar();
  5. mysql_query("INSERT INTO tabla(campo1)VALUE('$dato')");
  6. desconectar();
  7. ?>

conexion.php

Código php:
Ver original
  1. <?php
  2. function conectar()
  3. {
  4.     mysql_connect("localhost","root","");
  5.     mysql_select_db("nombre_base_datos");
  6. }
  7. function desconectar()
  8. {
  9.     mysql_close();
  10. }
  11. ?>

espero te sirva, suerte