Jump to content

Strange problem


wepnop

Recommended Posts

Im installing and testing a web application, and im having a strange bug that annoyes me because it dint have any sense and also it dont affects really to the web functionality:

 


if($_POST["eliminar"]==""){
$consulta='SELECT * FROM impressora where Activa=0';
	$result=mysql_query($consulta,$conexion);
echo"<table align=CENTER class='sample'>";
echo"<p align=center>LLISTA D'IMPRESSORES INACTIVES.</p>";
printf("<th>MODEL</th><th>MARCA </th>");

while($fila=mysql_fetch_array($result,MYSQL_ASSOC)){
	echo"<tr>";
	echo "<td>" . $fila["Model"] . "</td>";
	echo "<td>" . $fila["Marca"] . "</td>";
	echo"</td>";
	if($_SESSION["admin"]!=0){ 
?>
		<form method= "post" ACTION="impressores_inactives.php?idr=<?php echo($fila["Id_impressora"])?>">
		<td colspan="2"><INPUT TYPE ="SUBMIT" NAME="eliminar" VALUE="Eliminar"></td>
		</form></td>
<?php
	}
	echo "</tr>";
}
echo"</table>";	

}else{

echo 'eliminado';
echo $_POST["eliminar"];

//BORRAMOS DE LA BBDD LA IMPRESSORA
$consulta="delete from impressora where Id_impressora='".$_GET["idr"] ."'";
	$result=mysql_query($consulta);
	echo "<meta http-equiv=Refresh content=\" ; url=../Impressores/impressores_inactives.php\">"; 
}

 

The problem is that php say that eliminar is undefinded, and if i test $_POST it says its empty. See that eliminar is the name of the submit post and its checked for a function that deletes a item.

 

The problem is that script is actually working. I can delete the printer  but with that error... and if i test the value of eliminar is always empty.

 

Ask for any other explanation without a problem , the code is in spanish.

 

Link to comment
https://forums.phpfreaks.com/topic/227614-strange-problem/
Share on other sites

I resolved it, or well, thats what i think.

<?php
include("../cabecera.php");
if(!isset($_SESSION["admin"])){	
?><script>alert('NO TENS ACCÉS A AQUESTA SECCIÓ.')</script><?php
echo "<meta http-equiv=Refresh content=\" ; url=../Login/login.php\">"; 
exit();
}

include ("../Menu/menu.php");

# La accion de eliminar se va a ejecutar solo si el eliminar se ha pasado
if (isset($_POST['eliminar'])) {

# Ejecuta la opcion de eliminar si se ha pasado algun valor 
if (!empty($_POST['eliminar']) ) {

echo 'elm';
//BORRAMOS DE LA BBDD LA IMPRESSORA
	$consulta="delete from impressora where Id_impressora='".$_GET["idr"] ."'";
		$result=mysql_query($consulta);
		echo "<meta http-equiv=Refresh content=\" ; url=../Impressores/impressores_inactives.php\">"; 
}

# Si no se ha pasado ningun valor se imprime el formulario para dar las opciones
} else {

echo 'va';
$consulta='SELECT * FROM impressora where Activa=0';
	$result=mysql_query($consulta,$conexion);
echo"<table align=CENTER class='sample'>";
echo"<p align=center>LLISTA D'IMPRESSORES INACTIVES.</p>";
printf("<th>MODEL</th><th>MARCA </th>");

while($fila=mysql_fetch_array($result,MYSQL_ASSOC)){
	echo"<tr>";
	echo "<td>" . $fila["Model"] . "</td>";
	echo "<td>" . $fila["Marca"] . "</td>";
	echo"</td>";
	if($_SESSION["admin"]!=0){ 
?>
		<form method= "post" ACTION="impressores_inactives.php?idr=<?php echo($fila["Id_impressora"])?>">
		<td colspan="2"><INPUT TYPE ="SUBMIT" NAME="eliminar" VALUE="Eliminar"></td>
		</form></td>
<?php
	}
	echo "</tr>";
}
echo"</table>";	
}

include"../pie.php";
?>

Link to comment
https://forums.phpfreaks.com/topic/227614-strange-problem/#findComment-1174001
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.