PHP - cuadro de texto con mensaje

 
Vista:

cuadro de texto con mensaje

Publicado por sin dientes (115 intervenciones) el 20/06/2007 17:13:03
buenos dias,

tengo el sig. programa.

p1.php se ingresa la clave del articulo a borrar,

cuando se oprime boton llama a borra.php,

lo q deseo hacer es que en el momento de realizar el borrado si el articulo no existe despliegue un ventana o mensaje con la inf. debida y luego me regrese a la pantalla p1.php.

gracias por su ayuda.

saludos buen dia
Valora esta pregunta
Me gusta: Está pregunta es útil y esta claraNo me gusta: Está pregunta no esta clara o no es útil
0
Responder

RE:cuadro de texto con mensaje

Publicado por basnek (63 intervenciones) el 20/06/2007 19:58:35
Hola SD,
Bueno te comento como sería el tema para lo que deseas, cabe aclarar que hay otras formas como ser hacerlo con Ajax ó en el momento ó bien con un listado donde pulsa en el que quiere borrar. pero bueno vayamos a lo que puntualmente requieres dadoq ue seguro sera porque conoces los requerimientos exactos de esto.
Espero te sirva Salu2 y Éxitos

PD: Deberas editar lo que corresponde a datos de tablas obviamente. En mi caso, para el ejemplo, use esta estructura

# Table "445811_productos" DDL

CREATE TABLE `445811_productos` (
`productoID` int(10) unsigned NOT NULL auto_increment,
`codigo` varchar(20) default NULL,
`producto` varchar(50) default NULL,
PRIMARY KEY (`productoID`)
) TYPE=MyISAM


---[ 445811-p1.php]---
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>

<body>
<form id="form1" name="form1" method="get" action="445811-borrar.php">
<input name="codigo" type="text" id="codigo" />
<input type="submit" name="Submit" value="Enviar" />
</form>
</body>
</html>

---[ 445811-borrar.php]---
<?php require_once('Connections/cnx.php'); ?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
$theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;

$theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);

switch ($theType) {
case "text":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "long":
case "int":
$theValue = ($theValue != "") ? intval($theValue) : "NULL";
break;
case "double":
$theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
break;
case "date":
$theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
break;
case "defined":
$theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
break;
}
return $theValue;
}
}

$colname_rsProducto = "-1";
if (isset($_GET['codigo'])) {
$colname_rsProducto = (get_magic_quotes_gpc()) ? $_GET['codigo'] : addslashes($_GET['codigo']);
}
mysql_select_db($database_cnx, $cnx);
$query_rsProducto = sprintf("SELECT * FROM `445811_productos` WHERE codigo = %s", GetSQLValueString($colname_rsProducto, "text"));
$rsProducto = mysql_query($query_rsProducto, $cnx) or die(mysql_error());
$row_rsProducto = mysql_fetch_assoc($rsProducto);
$totalRows_rsProducto = mysql_num_rows($rsProducto);
if ($totalRows_rsProducto >0) {
// Aca rutina de borrar y luego
header("Location: 445811-p1.php");
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
</head>

<body>
<p>El producto
<?php echo (isset($_GET['codigo']))?htmlentities($_GET['codigo']):"N/D"; ?> 
No existe en la BBDD.</p>
<p><a href="javascript:history.back();">«volver</a></p>
</body>
</html>
<?php
mysql_free_result($rsProducto);
?>
Valora esta respuesta
Me gusta: Está respuesta es útil y esta claraNo me gusta: Está respuesta no esta clara o no es útil
0
Comentar