Академический Документы
Профессиональный Документы
Культура Документы
<?php
$cn=mysql_connect("localhost","root","123456789")or die("Error en Conexion");
$db=mysql_select_db("dg_motor2")or die("Error en Db");
return($cn);
return($db);
?>
Código de agregar
<?php
include("conexion.eliminar.php");
?>
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>ALTAS</title>
<style type="text/css">
body {
background-image: url(imagenes/seamless-vector-pattern-with-decorative-brushed-thin-
lines-in-white-and-grey-colors-texture-for-web-print-wallpaper-wedding_135309380.jpg);
}
</style>
</head>
<body onLoad="carga();">
<header>
</header>
<div id="leo">
<section id="leon">
<section id="leone">
<?php
$var="";
$var1="";
$var2="";
$var3="";
$var4="";
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];
if($btn=="Buscar"){
}
if($btn=="Agregar"){
$cod=$_POST["txtcod"];
$nom=$_POST["txtnom"];
$ape=$_POST["txtape"];
$tel=$_POST["txttel"];
$sex=$_POST["cbosex"];
$sql="insert into listaempleado values ('$cod','$nom','$ape','$tel','$sex')";
$cs=mysql_query($sql,$cn);
echo "<script> alert('empleado registrado correctamente');</script>";
}
}
?>
Código de formulario
<tr>
<td>Nombre</td>
<td><input type="text" name="txtnom" value="<?php echo $var1?>"/></td>
</tr>
<tr>
<td>Apellido</td>
<td><input type="text" name="txtape" value="<?php echo $var2?>"/></td>
</tr>
<tr>
<td>Telefono;</td>
<td><input type="text" name="txttel" value="<?php echo $var3?>"/></td>
</tr>
<td>Sexo</td>
<td><select name="cbosex">
<option>Femenino</option>
<option <?php echo $var4?> >Maculino</option>
</select></td>
</tr>
</table>
<br>
<tr align="center"><td colspan="2">
<input type="submit" name="btn1"value="Agregar"/></td></tr>
</table>