PHP - indice indefinido al cargar primera vez pagina

 
Vista:
sin imagen de perfil

indice indefinido al cargar primera vez pagina

Publicado por jhon figueroa (26 intervenciones) el 09/12/2010 06:50:12
necesito colaboracion de Ustedes....
al momento de cargar por primera vez la pagina me muestra el siguiente error:
Notice: Undefined index: Operarios in C:\wamp\www\cissnephp\ADMINISTRADOR\PERMISOS.php on line 2
se ha que se debe el error pero no se como hacer para que no se visualice....
alli va el codigo realizado :

<?php
$Operarios=$_GET['Operarios'];
session_start();
if($_SESSION['login']!='1')
{
header ("location: /Intranet.php");
exit;
}
else
{
$c=0;
?>
<!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>
<script language="javascript" type="">
function restablecer(){
document.forms["form1"]["Enviar"].disabled=true;
}
function verifica(){//verifica que el contenido ingresado sea valido

Nombre=document.getElementById("Nombre").value;
descripcion=document.getElementById("descripcion").value;

if(Nombre==null || Nombre.length==0 || /^\s+$/.test(Nombre)|| descripcion==null || descripcion.length==0 ){
document.forms["form1"]["Enviar"].disabled=true;
}else{
inabilita=true;
contar=1;
texto=Nombre;
while(contar<=2){
tamaño=texto.length;
for(i=0;i<tamaño;i++){
carac=texto.charCodeAt(i);
if(carac!=32){
if (carac<65 || carac>90){
if (carac<97 || carac>122){
if (carac!=130 || carac<160 || carac>165 ){
alert("EL SIGUIENTE VALOR NO ESTA PERMITIDO: "+texto.charAt(i));
inabilita=false;

}
}
}
}
}
contar++;
if(contar==2){
texto=descripcion;
}
}
if (inabilita==true){
document.forms["form1"]["Enviar"].disabled=false;
}
}
}
function activarequiere(){
requiere = document.getElementById("requiere").value;
if (requiere==1 || requiere==3 ){
document.getElementById("Nombre").value = "";
document.getElementById("descripcion").value ="";
document.forms["form1"]["Enviar"].disabled=true;
document.forms["form1"]["Nombre"].readOnly =false;
document.forms["form1"]["descripcion"].readOnly =false;
}
}
function volcar_valores(elemento){
requiere = document.getElementById("requiere").value;
if (requiere==1){
alert("ESTA FUNCION NO ESTA PERMITIDA PARA INGRESAR NUEVOS DATOS");
}else{
var td = elemento.id;
var a = "a"+td;

var b = "b"+td;

var td1 = document.getElementById(a).innerHTML;
var td2 = document.getElementById(b).innerHTML;

document.getElementById("Nombre").value = td1;
document.getElementById("descripcion").value =td2;
document.forms["form1"]["Enviar"].disabled=false;
document.forms["form1"]["Nombre"].readOnly =true;
if (requiere==3){
document.forms["form1"]["descripcion"].readOnly =true;
}else{
document.forms["form1"]["descripcion"].readOnly =false;
}
}
}

function enviarparametro(valor){
location = location.pathname + '?Operarios=' + valor;
}
window.onload = function(){
document.getElementById('Operarios').onchange = function(){
enviarparametro(this.value);
}
}

</script>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1" />
<title>Documento sin título</title>
<link href="CISSNE.css" rel="stylesheet" type="text/css" />
</head>

<body class="fondo">
<p>  </p>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote>
<blockquote> <blockquote>
<blockquote><blockquote>
<form id="form1" name="form1" method="post" action="guardapermiso.php">
<table width="569" border="0" class="INTRANET" >
<tr>
<th scope="col"> </th>
<th scope="col"><p>Usted desea---------------------->>: </p></th>
<th scope="col"><div align="left">
<select name="requiere" id="requiere" onchange="javascript:activarequiere();">
<option value="1">Agregar Nuevo</option>
<option value="2">Modificar</option>
<option value="3">Eliminar</option>
</select>
</div></th>
</tr>
<tr>
<th scope="col"><input name="Codigoformulario" type="hidden" /></th>
<th scope="col"> </th>
<th scope="col"> </th>
</tr>
<tr>
<th width="82" scope="col"> </th>
<th width="182" scope="col"><p>FORMULARIO ASIGNADO :</p></th>
<th width="271" scope="col"><label> </label>
<div align="left">
<select name="formulario" id="formulario" >
<?php
$link=mysql_pconnect("localhost","root","");
$resultados = mysql_select_db("cissne",$link);
$query="SELECT * FROM FORMULARIO ORDER BY Nombre";
$response = mysql_query($query,$link);
$c=0;
while($row = mysql_fetch_assoc($response)) {
echo " <option value=\"".$row["Codigoformulario"]."\">".$row["Nombre"]."</option>\n";
$c++;
}
?>
</select>
</div></th>
</tr>
<tr>
<td> </td>
<td><p>OPERARIO:</p></td>
<td> <div align="left">
<select name="Operario" >
<?php
$link=mysql_pconnect("localhost","root","");
$resultados = mysql_select_db("cissne",$link);
$query="SELECT * FROM OPERARIOS ORDER BY NOMBRES";
$response = mysql_query($query,$link);
$c=0;
while($row = mysql_fetch_assoc($response)) {
echo " <option value=\"".$row["CODOPERARIO"]."\">".$row["NOMBRES"]." ".$row["APELLIDOS"]."</option>\n";
$c++;
}
?>
</select></div></td>
</tr>
<tr>
<td> </td>
<td><label>
<input class="boton" name="Submit" type="reset" onclick="javascript:restablecer();" value="Restablecer" />
</label></td>
<td><input class="boton" disabled="disabled" name="Enviar" type="Submit" id="Enviar" value="Enviar" /></td>
</tr>
<tr>
<td> </td>
<td><p><a href="/menu.php">VOLVER</a></p></td>
<td> </td>
</tr>
<tr>
<td> </td>
<td> </td>
<td> </td>
</tr>
<tr>
<td> </td>
<td><p>Seleccione el operario a buscar</p> </td>
<td><div align="left">
<select name="Operarios" id="Operarios" onchange="javascript:enviarparametro(this.value);">
<option value="0">Seleccione</option>
<?php
$link=mysql_pconnect("localhost","root","");
$resultados = mysql_select_db("cissne",$link);
$query="SELECT * FROM OPERARIOS ORDER BY NOMBRES";
$response = mysql_query($query,$link);
$c=1;
while($row = mysql_fetch_assoc($response)) {
echo " <option value=\"".$row["CODOPERARIO"]."\">".$row["NOMBRES"]." ".$row["APELLIDOS"]."</option>\n";
$c++;
}
?>
</select></div></td>
</tr>
<tr>
<td><h2></h2></td>
<td><h2>TIPO</h2></td>
<td><h2>DESCRIPCIÓN</h2></td>
</tr>
<?PHP
$link=mysql_pconnect("localhost","root","");
$resultados = mysql_select_db("cissne",$link);
$query=sprintf("SELECT * FROM PERMISOS WHERE CODOPERARIO ='%s'",$Operarios);
$response = mysql_query($query,$link);
$c=0;
while($row = mysql_fetch_assoc($response)) {
?>
<tr class="par">
<td><input id=<?php echo $c ?> class="boton" name="Recargar" type="button" onclick="javascript:volcar_valores(this);" value="Recargar" /></td>
<td id=<?php echo 'a'.$c ?> ><?php echo $row["Codigoformulario"] ?></td>
<td id=<?php echo 'b'.$c ?> ><?php echo $row["CODOPERARIO"] ?></td>
<?PHP
$c++;
}
?>
</tr>
</table>
</form>




</blockquote></blockquote></blockquote></blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</blockquote>
</body>
</html>
<?php
}
?>
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:indice indefinido al cargar primera vez pagina

Publicado por Miro (13 intervenciones) el 09/12/2010 14:54:05
En la siguiente linea puede poner el condicional para evitar el error. Entonces quedaria algo asi:
//$Operarios=$_GET['Operarios'];
$Operarios=(isset($_GET['Operarios']))?$_GET['Operarios']:"";
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
sin imagen de perfil

RE:indice indefinido al cargar primera vez pagina

Publicado por JHON FIGUEROA (26 intervenciones) el 10/12/2010 07:42:33
Gracias por la sugerencia.......

FUNCIONA PERFECTAMENTE.....

ATT

JHON JAIRO FIGUEROA CH
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