Foros del Web » Programando para Internet » PHP »

Problemita con puntuacion

Estas en el tema de Problemita con puntuacion en el foro de PHP en Foros del Web. Bueno, en la pagina que estoy desarrollando, hay un sistema de puntuacion, el cual hasta hace un tiempo funcionaba perfecto, lo deje de usar (1 ...
  #1 (permalink)  
Antiguo 02/11/2009, 07:42
 
Fecha de Ingreso: julio-2009
Ubicación: Argentina!
Mensajes: 324
Antigüedad: 14 años, 8 meses
Puntos: 4
Problemita con puntuacion

Bueno, en la pagina que estoy desarrollando, hay un sistema de puntuacion, el cual hasta hace un tiempo funcionaba perfecto, lo deje de usar (1 mes aproximadamente) ya que tenia que terminar otras cosas, despues hice un cambio significativo (a mi modo de ver las cosas), cambie include_once por require y $_GET por $_POST, luego de hacer el cambio, me dejo de funcionar , probe volver todo a $_GET como estaba antes y nada, entonces, para ver que era lo que pasaba, me fui al zend debugger y lo ejecute paso a paso, FUNCIONO TODO! sin ningun error, fue cuando pense " Mi pc se volvio loca o yo necesito un nuevo cerebro. ", bueno, volvi a Firefox para correr la pagina, y bueno, NO FUNCIONO! en una de esas, voy a IE a probar la pagina, y ahi SI FUNCIONO! entonces.... ya no entiendo nada, antes andaba perfecto en FF y IE, ahora solo en IE!. Probe con copias anteriores del sistema, y ahora no funciona la puntuacion en ninguna, siendo que andaba perfecto! Ya no entiendo nada!, dejo el codigo para ver si alguien tiene alguna idea o si le paso algo similar.

Calificar.php
Código PHP:
<?php 
require("template.php");

$clave=$_POST['clave'];
set_file("todo","calificar.html");
set_var("clave",$clave);
pparse("todo");
?>

Calificar.html
Código PHP:
<script type="text/javascript">

function 
validar(e) { // 1
    
tecla = (document.all) ? e.keyCode e.which// 2
    
if (tecla==8) return true// 3
    
patron =/[<>]/; // 4
te String.fromCharCode(tecla); // 5
return !patron.test(te); // 6
}

function 
textCounter(fieldcountfieldmaxlimit) {
if (
field.value.length maxlimit// if too long...trim it!
field.value field.value.substring(0maxlimit);
// otherwise, update 'characters left' counter
else 
countfield.value maxlimit field.value.length;
}



function 
valida_envia(){
var 
Promo1=form1.tipopuntuacion[0].checked;
var 
Promo2=form1.tipopuntuacion[1].checked;
var 
Promo3=form1.tipopuntuacion[2].checked;


     if ((
Promo1==false) && (Promo2==false) && (Promo3==false)){
     
alert("Debe Marcar un Tipo de Puntuacion");
     return 
0;
    }
    
   if (
document.form1.message.value.length==0){
   
alert("Debe Ingresar un Comentario.");
   return 
0;
    }

    
document.form1.action "guarda_calificacion.php?clave={clave}";
    
document.form1.submit();

   }
   
   
   
 
</script>
 <style type="text/css">
 #centrado-total ul{

    list-style:none;
    text-align: center; /*esto pone el ul centrado horiz*/
    line-height: 22px; /*esto iguala el height del div y lo centra vertical*/
    margin: auto; /*reseteado de márgenes*/
    width: 470px; /*tamaño del div */
    border:1px solid #000000;
    background: #FFC;
    font-size: 12px;

}
 </style>

</head>

<body>

<br><br>
<form name="form1" method="post" action="guarda_calificacion.php"><div align="center">
   <table width="80%" style="border-top-style:solid;border-right-style:solid;border-bottom-style:none;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;" border="0" cellspacing="0" cellpadding="0">
    <tr>
      <td background="mas_buscados_titulo_fondo.jpg"><div align="center"><strong>Usa este formulario para calificar a los vendedores</strong></div></td>
    </tr>
  </table>
  <table width="80%" style="border-top-style:none;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;" border="0" bordercolor="#000000" align="center" cellpadding="0" cellspacing="0">
   <tr>
     <td width="23%" bgcolor="#FFE8AC">&nbsp;</td>
     <td width="50%" rowspan="4" bgcolor="#FFE8AC"><p>
       <textarea name="message"  wrap="physical" cols="60" rows="5"
onKeyDown="textCounter(this.form.message,this.form.remLen,600);"
onKeyUp="textCounter(this.form.message,this.form.remLen,600);" onpaste="return false" oncopy="return false" onKeyPress="return validar(event)" id="message"></textarea>
     </p>
       <p align="center">caracteres restantes:
         <input readonly type="text" name="remLen" size="3" maxlength="3" value="600">
</p></td>
     <td width="27%" bgcolor="#FFE8AC"> <input type="radio" name="tipopuntuacion" id="radio" value="+1">
     +1</td>
   </tr>
   <tr>
     <td bgcolor="#FFE8AC"><center>
        Comentario:
     </center> </td>
     <td bgcolor="#FFE8AC"><input type="radio" name="tipopuntuacion" id="radio2" value="neutro">
     Neutro</td>
   </tr>
   <tr>
     <td rowspan="2" bgcolor="#FFE8AC">&nbsp;</td>
     <td bgcolor="#FFE8AC"> <input type="radio" name="tipopuntuacion" id="radio3" value="-1">
     -1</td>
   </tr>
   <tr>
     <td bgcolor="#FFE8AC">&nbsp;</td>
   </tr>
   <tr>
     <td colspan="3" bgcolor="#FFE8AC"><center> 
       <input type="submit" name="Enviar" id="Enviar" onClick="valida_envia()" value="Enviar">
       <label>
       <input type="reset" name="Restablecer" id="Restablecer" value="Restablecer">
       </label>
       <label>
<input type="button" name="cancelar" id="cancelar" value="Cancelar" onClick="javascript:history.go(-1)"  >
       </label>
     </center></td>
     </tr>
 </table>
      
      </div> 
</form> 
SIGUE ABAJO
  #2 (permalink)  
Antiguo 02/11/2009, 07:43
 
Fecha de Ingreso: julio-2009
Ubicación: Argentina!
Mensajes: 324
Antigüedad: 14 años, 8 meses
Puntos: 4
Respuesta: Problemita con puntuacion

CONTINUACION



Guarda_calificacion.php

Código PHP:
<?php
require("template.php");
$comentario=$_REQUEST['message'];
$subject1=$comentario;
$eviltags = array

(
'<','body:','>','</','/');
for(
$i=0;$i<sizeof($eviltags);$i++){
if(
strstr($subject1$eviltags[$i])){
unset(
$subject1);
die(
" <div align=\"center\">    <br />
  <table width=\"80%\" style=\"border-top-style:solid;border-right-style:solid;border-bottom-style:none;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;\" border=\"0\" cellspacing=\"0\" cellpadding=\"0\">
    <tr>
      <td height=\"21\" background=\"mas_buscados_titulo_fondo.jpg\"><div align=\"center\" class=\"Estilo3\">Error</div></td>
      </tr>
  </table>
  <table style=\"border-top-style:none;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;\" width=\"80%\"  cellspacing=\"0\" cellpadding=\"0\">
    <tr>
      <td bgcolor=\"#ffe8ac\"><div align=\"center\"><span class=\"Estilo2\"><br>
            <strong>Su comentario contiene caracteres no validos.</strong><br>
      </span><br />
          <input type=\"submit\" value=\"Volver\" onClick=\"history.go(-1)\" />
        </div><br></td>
      </tr>
  </table>
  </div>"
);
}
}

$clave=$_REQUEST['clave'];
$tipopuntuacion $_REQUEST['tipopuntuacion'];

if (
$tipopuntuacion == '+1') {
    
$puntaje=1;
    }
else if (
$tipopuntuacion == 'neutro') {
    
$puntaje=0;
    }
else if (
$tipopuntuacion == '-1') {
    
$puntaje2;
    }


$sql="UPDATE puntajes SET clave2='0', puntaje='$puntaje', comentariocomprador='$comentario' WHERE clave='$clave'";
$res=mysql_query($sql) or die($error="No se pudo guardar su respuesta");
$lugarlog=1;
logbases();
if(
$res==FALSE){
die(
$error="No se pudo guardar su respuesta");
}

$contador 0;
$positivo NULL;
$neutro NULL;
$negativo NULL;

$sql="SELECT * FROM puntajes WHERE clave = '$clave'";
$res=mysql_query($sql);
$resultado=mysql_fetch_array($res);
$lugarlog=2;
logbases();


$useridvendedor=$resultado[useridvendedor];


$sql="SELECT * FROM puntajes WHERE useridvendedor = '$useridvendedor' and clave2 = '0'";
$res=mysql_query($sql);
$lugarlog=3;
logbases();

while (
$resultado=mysql_fetch_array($res)){
$lugarlog=4;
logbases();

$puntaje=$resultado[puntaje];


$contador=$contador+1;


if (
$puntaje == ){
$positivo=$positivo+1;
}
if (
$puntaje == ){
$neutro=$neutro+1;
}
if (
$puntaje == ){
$negativo=$negativo+1;
}
}

if (
$positivo !==NULL){
$total1=$positivo/$contador*100;
}
if (
$negativo !==NULL){
$total3=$negativo/$contador*100;
}
if (
$neutro !==NULL){
$total2=$neutro/$contador*100;
}
if (
$negativo !==NULL){
$total3=$negativo/$contador*100;
}

$sql="UPDATE porcentaje SET positivo='$total1', neutro='$total2', negativo='$total3', votos='$contador' WHERE userid='$useridvendedor'";
$res=mysql_query($sql);

$lugarlog=5;
logbases();
if(
$res==FALSE){
die(
$error="No se pudo guardar su respuesta");
}



echo 
"<table width='50%' style=\"border-top-style:solid;border-right-style:solid;border-bottom-style:none;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;\" border='0' align='center' bgcolor='#FFFFCC' background=\"mas_buscados_titulo_fondo.jpg\" cellpadding='0' cellspacing='0'>
    <tr>
      <td><center><strong>Su calificacion a sido ingresada</strong></center>

      </td>
    </tr>
  </table>
<table width='50%' style=\"border-top-style:none;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 2px;border-right-width:2px;border-bottom-width:2px;border-left-width:2px;\" border='0' align='center' bgcolor='#FFE8AC'  cellpadding='0' cellspacing='0'>
<tr>
<td>
<form id='form1' name='form1' method='post' action='dar_puntos.php'>
<center><input type='submit' name='volver2' id='volver2' value='Volver' /></center>
</form>
</td>
</tr>
</table>"
;





function 
logbases() {
        global 
$lugarlog;
$fechalog=date("Y-m-d");
$mysql_errno_logmysql_errno();
$mysql_error_log mysql_error();
$programa "GUARDA_CALIFICACION.PHP"
$errorlog $lugarlog;
if (
mysql_errno() !== 0){
$sql="SELECT * FROM log  where fecha  = '$fechalog' and nroerror = '$mysql_errno_log' and msgerror = '$mysql_error_log' and lugarlog = '$errorlog'";
$res1h=mysql_query($sql);
if (
$reslh !== FALSE){
$reg1=mysql_num_rows($res1h);
}else{
$reg1=0;
}
if  (
$reg1 <= 0){
$sql="INSERT ignore INTO log (fecha,nroerror,msgerror,programa,lugarlog)    VALUES ('$fechalog','$mysql_errno_log','$mysql_error_log','$programa','$errorlog')";
mysql_query($sql) or die ("<table width=\"50%\" border=\"0\" style=\"border-top-style:solid;border-right-style:solid;border-bottom-style:none;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\">
  <tr>
    <td height=\"21\" background=\"mas_buscados_titulo_fondo.jpg\"><div align=\"center\"><strong>Error</strong></div></td>
  </tr>
</table>
<table width=\"50%\" border=\"0\" style=\"border-top-style:none;border-right-style:solid;border-bottom-style:solid;border-left-style:solid;border-top-color:#000000;border-right-color:#000000;border-bottom-color:#000000;border-left-color:#000000;border-top-width: 1px;border-right-width:1px;border-bottom-width:1px;border-left-width:1px;\" align=\"center\" cellpadding=\"0\" cellspacing=\"0\" >
  <tr>
    <td bgcolor=\"#FFE8AC\"><div align=\"center\"><strong><br />Problema insertando LOG</strong></div></td>
  </tr>
  <input type=\"button\" value=\"volver\" onClick=\"history.go(-1)\">
</table>"
);
}
}


mysql_close();


?>

Otra cosa que recuerdo, desde que no funciona, el form del Calificar.html estaba llamandose a si mismo, es decir action="calificar.html" cuando yo lo tenia como action="guarda_calificacion.php", y les juro que nadie nadie toco eso! (Hay fantasmas en mi pc? )

Un abrazo
Atención: Estás leyendo un tema que no tiene actividad desde hace más de 6 MESES, te recomendamos abrir un Nuevo tema en lugar de responder al actual.
Respuesta




La zona horaria es GMT -6. Ahora son las 23:10.