Ver Mensaje Individual
  #9 (permalink)  
Antiguo 24/10/2008, 05:46
EphramDoyle
 
Fecha de Ingreso: enero-2008
Mensajes: 43
Antigüedad: 16 años, 3 meses
Puntos: 1
Respuesta: Error insert to

Para hacerlo sencillo un simple insert lo resumo en esto (insertar solo fila con Level y Name):

index (formulario)

Código:
     <form action="codigoinsert.php" method="POST">
<table border="0" cellpadding="0" cellspacing="0" id="tienda" style="border:0px solid #000000;">

<tr>
	  <td align="right">
	  <div align="left">Level:</div></td>
	  <td align="right"><div align="left">
	  <input type="text" size="25" maxlength="250" name="Level">
	  </div></td>
</tr>
<tr>

<td align="right">
	  <div align="left">Name:</div></td>
	  <td align="right"><div align="left">
	  <input type="text" size="25" maxlength="250" name="Name">
	  </div></td>
</tr>
<tr>

</tr>

<tr>
  <td colspan="2" align="center"><input name="submit" type="submit" value="Insertar objeto"></td>
</tr>
</table>
</form>

codigoinsert.php
Código:
<?PHP
// Configura los datos de tu cuenta
$dbhost='localhost';
$dbusername='****';
$dbuserpass='****';
$dbname='*****';

// Conexión a la base de datos
mysql_connect ($dbhost, $dbusername, $dbuserpass);
mysql_select_db($dbname) or die("Cannot select database");

// Preguntaremos si se han enviado ya las variables necesarias
if (isset($_POST[Level])) {
$Level = $_POST[Level];
$Name = $_POST[Name];

// Hay campos en blanco
if (empty($Level) or empty($Name)){
header("location:http://www.gilgo-designs.es/login/reg_cam_vacio.php");
}else{
//Todo parece correcto procedemos con la inserccion
$query = "INSERT INTO tienda (Level, Name) VALUES ($_POST[Level],$_POST[Name])";

mysql_query($query) or die(mysql_error());
header("location:http://www.gilgo-designs.es/login/reg_correcto.php");
exit();
}
}
?>