Código PHP:
<?php
session_start();
if ($_SESSION['login'] != "ok"){
header("Location: entrar.php");
}
$usuario="root";
$password="";
$bd="busqueda";
$link=mysql_connect('localhost',$usuario,$password);
mysql_select_db($bd) or die ("No podemos conectar con la BD");
if(isset($_POST['alta'])){
$query="INSERT INTO datos( nombre,apellidos,email,departamento,extension ) VALUES('$_POST[nombre]','$_POST[apellidos]','$_POST[email]','$_POSTdepartamento]','$_POST[extension]')";
mysql_query($query, $link) or die(mysql_error());
if (mysql_affected_rows() != 0){
$texto = 'Operación realizada correctamente';
}else{
$texto = 'Operación NO realizada correctamente';
}
}else{
$texto = 'Error operación no permitida';
}
?>
<html>
<head>
<style type:="text/css">
body {
font-style:italic;
margin: 0 auto;
font-family: arial;
text-align:center;
background-color: #F0F0F0;
vertical-align:center;
background-image:url(../../../../Users/usuario/Desktop/fondo-cabecera.png);
background-repeat:repeat-x;
}
#cabecera{
background-color:#000;
background-repeat:repeat;
margin-top:40px;
margin-bottom:60px
}
#tabla1{
font-weight: bold;
color: red;
height:auto;
width:auto;
overflow: hidden;
class="fija";
font-family: Arial;
font-size: 20px;
font-style: normal;
line-height: normal;
text-transform: capitalize;
margin-top:120 px;
}
#tabla2{
font-weight: bold;
color: red;
height:auto;
width:auto;
overflow: hidden;
class="fija";
font-family: Arial;
font-size: 20px;
font-style: normal;
line-height: normal;
text-transform: capitalize;
margin-top:120 px;
}
#general{
width:960px;
margin-top:60px;
margin-left:225px;
}
p {
font-family: Arial;
font-size: 12px;
font-weight:normal;
}
#barra{
background-repeat:repeat;
background-image: url(../../../../Users/usuario/Desktop/BARRA-INFERIOR.jpg);
margin-top:20px;
}
#link{
margin-top:345px;
font-family:arial;
font-size:14px;
font-weight:bold;
}
</style>
</head>
<body>
<div>
Insertar un campo nuevo:
</div>
<div>
<form method="post" name="datos" action="<?php $_SERVER['../../../../Users/usuario/Desktop/PHP_SELF']?>">
<table>
<tr>
<td>Nombre:</td>
<td><input type="text" name="nombre" /></td>
</tr>
<tr>
<td> Apellidos:</td>
<td><input type="text" name="apellidos" /></td>
</tr>
<tr>
<td>Correo: </td>
<td><input type="text" name="email" /></td>
</tr>
<tr>
<td>Departamento: </td>
<td><input type="text" name="departamento" /></td>
</tr>
<tr>
<td>Extension:</td>
<td><input type="text" name="extension" /></td>
</tr>
</table>
<br><input type="submit" name="alta" value="Dar de alta"/>
</form>
</div>
<div id="tabla1">
Eliminar un registro
<form method="POST" name="cuadros" action="../../../../Users/usuario/Desktop/bajausuario.php">
<p>Email<input type="text" name="email" /></p>
<p><br><input type="submit" name="baja" value="borrar"/></p>
</form>
<div align="center"><a href="mostrar.php">Visualizar el contenido de la tabla</a></div>
</div>
</body>
</html>