ayuda con la conexión a bd
Publicado por NANCY (2 intervenciones) el 24/12/2014 06:26:59
tengo el siguiente código ,que debería guardarme los datos ingresados del formulario pero tengo un error
ayuda¡¡¡¡¡¡¡¡¡¡¡
formulario.php
procesar.php
conexion.php
ayuda¡¡¡¡¡¡¡¡¡¡¡
formulario.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
<html>
<head>
<title>Guardar datos en una base de datos</title>
</head>
<body>
<form action="procesar.php" method="post" name="form">
<table width="200" border="0">
<tr>
<td>Nombre</td>
<td><input type="text" name="nombre" /></td>
</tr>
<tr>
<td>Telefono</td>
<td><input type="number" name="telefono" /></td>
</tr>
<tr>
<td> </td>
<td><input type="submit" value="Insertar datos" /></td>
</tr>
</table>
</form>
</body>
</html>
procesar.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
<?php
include("conexion.php");
if(isset($_POST['nombre']) && !empty($_POST['nombre'])&&
isset($_POST['telefono'] )&& !empty($_POST['telefono']))
{
$conexion=mysql_connect($host,$user,$pw)or die ("error al conectar");
mysql_select_db($bd,$conexion)or die ("error al conectar");
mysql_query("INSERT INTO profesores (nombre,telefono)
VALUES('$_POST[nombre]','$_POST[telefono]')",$conexion);
echo "datos insertados correctamente";
}else{
echo"error al insertar datos";
}
?>
conexion.php
1
2
3
4
5
6
7
8
<?php
$host="localhost";
$user="root";
$pw="admin";
$bd="pagina";
?>
Valora esta pregunta


0