<?php include("seguridad.php");?>
<?php
include("conexion.php");
?>
<!DOCTYPE html>
<html>
<head>
<title>Clientes</title>
<meta charset="utf-8">
<style type="text/css">
body {
background-color: #E2E2E2;
}
</style>
</head>
<body>
<header>
<h2><center>
INGRESO Y CONSULTAS DE CLIENTES<br>
Usuario: <? echo $_SESSION["usuarioactual"]; ?>
</center></h2>
</header>
<div id="leo">
<section id="leon">
<section id="leone">
<a href="logout.php"></a><br><a href="proyecto.php"></a></br>
<?php
$var="";
$var1="";
$var2="";
$var3="";
$var4="";
$var5="";
$var6="";
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];
$bus=$_POST["txtbus"];
if($btn=="Buscar"){
$sql="select * from empresas where idempresa='$bus'";
$cs=mysql_query($sql,$cn);
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];
$var4=$resul[4];
$var5=$resul[5];
$var6=$resul[6];
}
}
if($btn=="Agregar"){
$nitemp=$_POST["txtnitemp"];
$nomemp=$_POST["txtnomemp"];
$dir=$_POST["txtdir"];
$tel=$_POST["txttel"];
$email=$_POST["txtemail"];
$nomcon=$_POST["txtnomcon"];
$telcon=$_POST["txttelcon"];
$sql="insert into empresas values ('$nitemp','$nomemp','$dir','$tel','$email','$nomc on','$telcon')";
$cs=mysql_query($sql,$cn);
echo "<script> alert('Se inserto correctamente');</script>";
}
if($btn=="Actualizar"){
$nitemp=$_POST["txtnitemp"];
$nomemp=$_POST["txtnomemp"];
$dir=$_POST["txtdir"];
$tel=$_POST["txttel"];
$email=$_POST["txtemail"];
$nomcon=$_POST["txtnomcon"];
$telcon=$_POST["txttelcon"];
$sql="update empresas set nomempresa='$nomemp',direccion='$dir',telefono='$t el',email='$email',nomcontacto='$nomcon',telcontac to='$telcon'where idempresa='$nitemp'";
$cs=mysql_query($sql,$cn);
echo "<script> alert('Se actualizo correctamente');</script>";
}
}
?>
<form name="fe" action="" method="post">
<center>
<table border="2">
<tr>
<td><input type="submit" name="btn1" value="Listar Clientes"/></td>
<td><a href="empresas.php"><img src="cliente.png" width="107" height="23"></a></td>
</tr>
<tr align="center">
<td colspan="2"><a href="pedidos.php"></a><a href="proyecto.php"><img src="regresar.PNG" width="68" height="26"></a></td>
</tr>
<tr align="center">
<td colspan="2"><a href="logout.php"><img src="sesion.PNG" width="97" height="24"></a></td></tr>
</table>
</center>
<br />
<hr>
</form>
<br />
<?php
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];
if($btn=="Listar Clientes"){
$sql="select * from empresas";
$cs=mysql_query($sql,$cn);
echo"<center>
<table border='3'id='tabla'>
<tr>
<td>Nit Empresa</td>
<td>Nombre Empresa</td>
<td>Direccion</td>
<td>Telefono</td>
<td>Email</td>
<td>Nombre Contacto</td>
<td>Telefono Contacto</td>
<td>Funciones</td>
</tr>";
while($resul=mysql_fetch_array($cs)){
$var=$resul[0];
$var1=$resul[1];
$var2=$resul[2];
$var3=$resul[3];
$var4=$resul[4];
$var5=$resul[5];
$var6=$resul[6];
echo "<tr>
<td>$var</td>
<td>$var1</td>
<td>$var2</td>
<td>$var3</td>
<td>$var4</td>
<td>$var5</td>
<td>$var6</td>
<td>
<form action='procesosrequeridos.php' method='POST'>
<a href='editarempresa.php?nit=$var&empresa=$var1&dir eccion=$var2&tel=$var3&email=$var4&nomcon=$var5&te lcon=$var6'><img src='editar.PNG' width='87' height='24'></a>
<input type='submit' name='btn1' value='Eliminar'/>
<input type='hidden' name='id' value=".$var.">
</form>
</td>
</tr>";
}
echo "</table>
</center>";
}
}
?>
(omitan la funcion actualizar y agregar que los deje alli mas no los uso)
__________________________________________________ _______________
y este es el php que llamo supuestamente con el boton eliminar:
<?php include("conexion.php");?>
<?php
if(isset($_POST["btn1"])){
$btn=$_POST["btn1"];
if($btn=='Eliminar'){
$sql="delete from empresas where idempresa='$var'";
mysql_query($sql);
}header("Location:indexempresa.php");
echo "<script> alert('Registro eliminado correctamente');</script>";
}
?>
(pero lo unico que hace es refrescar la pagina... le agradezco su ayuda!)
