bueno ve acabo de modificar todo mira como lo tengo
conexion.php
funciones.php
insert-demo1.php
insert-demo2.php
insert-demo3.php
lo acomode asi no le ingrese mas campos solo esos 3 para probar pero nada todavia sigue sin ingresar campos
conexion.php
Código (php) [Seleccionar]
<?php
$conexion = mysql_connect("localhost", "root", "") or trigger_error(mysql_error(),E_USER_ERROR);
mysql_select_db("carrito", $conexion);
?>
funciones.php
Código (php) [Seleccionar]
<?php
function getParam($param, $default) {
$result = $default;
if (isset($param)) {
$result = (get_magic_quotes_gpc()) ? $param : addslashes($param);
}
return $result;
}
function sqlValue($value, $type) {
$value = get_magic_quotes_gpc() ? stripslashes($value) : $value;
$value = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($value) : mysql_escape_string($value);
switch ($type) {
case "text":
$value = ($value != "") ? "'" . $value . "'" : "NULL";
break;
case "int":
$value = ($value != "") ? intval($value) : "NULL";
break;
case "double":
$value = ($value != "") ? "'" . doubleval($value) . "'" : "NULL";
break;
case "date":
$value = ($value != "") ? "'" . $value . "'" : "NULL";
break;
}
return $value;
}
?>
insert-demo1.php
Código (php) [Seleccionar]
<?php
require("conexion.php");
// insertarmos el registro
mysql_query("INSERT INTO producto (codigo, nombre, nota) VALUES ('Apple', '1 Infinite Loop, Cupertino', 899610)");
// obtenemos el ID del registro
echo mysql_insert_id();
?>
insert-demo2.php
Código (php) [Seleccionar]
<?php
require("conexion.php");
$status = "";
if (isset($_POST["codigo"])) {
$codigo = $_POST["codigo"];
$nombre = $_POST["nombre"];
$nota = $_POST["nota"];
$sql = "INSERT INTO producto (codigo, nombre, nota) ";
$sql.= "VALUES ('".$codigo."', '".$nombre."', '".$nota."')";
mysql_query($sql, $conexion);
$status = "ok";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PHP con MySQL: Insertar datos en MySQL</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>Nueva Empresa</h3>
<?php if ($status == "ok") { ?>
<p class="confirm">Registro guardado correctamente</p>
<?php } ?>
<form method="post" id="frEmpresa" action="insert-demo2.php">
<label for="nombre">Nombre</label>
<input type="text" id="nombre" name="nombre" />
<br />
<label for="direccion">Dirección</label>
<input type="text" id="direccion" name="direccion" />
<br />
<label for="telefono">Telefono</label>
<input type="text" id="telefono" name="telefono" />
<br />
<label for="bts"> </label>
<button type="submit">Guardar</button>
<button type="reset">Limpiar</button>
</form>
</body>
</html>
insert-demo3.php
Código (php) [Seleccionar]
<?php
require("conexion.php");
require("funciones.php");
$status = "";
if (isset($_POST["codigo"])) {
$nombre = sqlValue($_POST["codigo"], "text");
$direccion = sqlValue($_POST["nombre"], "text");
$telefono = sqlValue($_POST["nota"], "text");
$sql = "INSERT INTO producto (codigo, nombre, nota) ";
$sql.= "VALUES ('".$codigo."', '".$nombre."', '".$nota."')";
echo $sql;
mysql_query($sql, $conexion);
$status = "ok";
}
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
<title>PHP con MySQL: Insertar datos en MySQL</title>
<link href="styles.css" rel="stylesheet" type="text/css" />
</head>
<body>
<h3>Nueva Empresa</h3>
<?php if ($status == "ok") { ?>
<p class="confirm">Registro guardado correctamente</p>
<?php } ?>
<form method="post" id="frEmpresa" action="insert-demo3.php">
<label for="nombre">Nombre</label>
<input type="text" id="nombre" name="nombre" />
<br />
<label for="direccion">Dirección</label>
<input type="text" id="direccion" name="direccion" />
<br />
<label for="telefono">Telefono</label>
<input type="text" id="telefono" name="telefono" />
<br />
<label for="bts"> </label>
<button type="submit">Guardar</button>
<button type="reset">Limpiar</button>
</form>
</body>
</html>
lo acomode asi no le ingrese mas campos solo esos 3 para probar pero nada todavia sigue sin ingresar campos