Ver Mensaje Individual
  #1 (permalink)  
Antiguo 09/06/2012, 13:27
oliverm
 
Fecha de Ingreso: noviembre-2008
Mensajes: 23
Antigüedad: 15 años, 5 meses
Puntos: 0
Error al conectar PHP con BBDD

Buenas, primero que nada debo aclarar que jamás he tenido una clase de PHP, solo tuve programación en pascal :S. Pero ahora estoy en un curso de BBDD y he visto SQL, pero para el lunes me pidieron como trabajo hacer una página web en html con scripts en PHP (ni si quiera sé si estoy usando las palabras correctas) para hacer consultas a mi base de datos.

Bueno, les pongo el código PHP que armé primero:

Código HTML:
<!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>Untitled Document</title>
</head>



<body>

<form action="../../Users/Oliver/Desktop/intentos php/insert.php" method="post">
<b>Formulario de registro de Cliente</b> <br><br>

Primer nombre: <input type="text" name="nombre"><br>
Primer apellido: <input type="text" name="apellido"><br>
RUT: <input type="text" name="rut_c"><br>
Calle y número: <input type="text" name="calle_nro"><br>
Comuna: <input type="text" name="comuna"><br>
Región: <input type="text" name="region"><br>

<input type="submit" value="Registrar">
</form>



<?

$hostname="localhost";
$username="root";
$password="xxxxxxx";   //CLAVE PUESTA EN XAMPP EN LA PARTE DE CHEQUEO DE SEGURIDAD
$db="omohr4";

$nombre=$_POST['nombre'];
$apellido=$_POST['apellido'];
$rut_c=$_POST['rut_c'];
$calle_nro=$_POST['calle_nro'];
$comuna=$_POST['comuna'];
$region=$_POST['region'];

mysql_connect($host,$username,$password);
@mysql_select_db($db);
$query="SELECT rut_c, fecha, id_orden_pedido 
	   FROM orden_pedido";
$query2 = "INSERT INTO `empleado` (`rut_c`, `nombre`, `apellido`, `calle_nro`, `comuna`, `region`) VALUES ('$rut_c','$nombre','$apellido','$calle_nro','$comuna','$region')";
$registro=mysql_query($query2);

echo "Historial de ordenes de pedido hechas por clientes:";

$result=mysql_query($query);
 

?>

</body>
</html> 

Esto imprime bien hasta el botón registrar y luego me tira el siguiente error:


Notice: Undefined index: nombre in C:\xampp\htdocs\aers.php on line 34

Notice: Undefined index: apellido in C:\xampp\htdocs\aers.php on line 35

Notice: Undefined index: rut_c in C:\xampp\htdocs\aers.php on line 36

Notice: Undefined index: calle_nro in C:\xampp\htdocs\aers.php on line 37

Notice: Undefined index: comuna in C:\xampp\htdocs\aers.php on line 38

Notice: Undefined index: region in C:\xampp\htdocs\aers.php on line 39

Notice: Undefined variable: host in C:\xampp\htdocs\aers.php on line 41

Warning: mysql_connect() [function.mysql-connect]: Access denied for user 'root'@'localhost' (using password: YES) in C:\xampp\htdocs\aers.php on line 41
Historial de ordenes de pedido hechas por clientes: