Foro de elhacker.net

Programación => PHP => Mensaje iniciado por: viher en 26 Agosto 2010, 21:57 pm



Título: problema forumulario y captcha
Publicado por: viher en 26 Agosto 2010, 21:57 pm
hola,pues tengo el siguiente codigo:

Código
  1. <form action="addcomentario.php"
  2.      method="post">
  3.                    <p>
  4.                      <input type="hidden" name="id_noticia" value="<? $id = $_GET['id'];
  5.  echo "$id"; ?>" />
  6.                      Nick :
  7.                      <label for="textfield"></label>
  8.                      <br />
  9.                      <input type="text" name="nick" size="20" maxlength="20" />
  10.                      <br />
  11.                      <br />
  12.                      Comentario:<br />
  13.                      <textarea name="comentario" cols="28" rows="6"></textarea>
  14.                      <br><table cellpadding=1>
  15.  <tr><td align="center"><?php dsp_crypt(0,1); ?></td></tr>
  16.  <tr><td align="center">Introduce el código:<br><input type="text" name="code"></td></tr>
  17. </table><br>
  18.                      <input type="submit" class="boton" value="Enviar" name="submit" />
  19.                    </p>
  20.                  </form>

que está con un captcha que me bajé,el caso es que si en el formulario en method lo pongo con POST me funciona el captcha pero no me obtiene el id_noticia y añade un comentario todalmente en blanco y no me sirve de nada,y si pongo el method en GET me obtiene el id_noticia pero no me funciona el script del captcha.He estado probando con otros scripts de captcha desde reCAPTCHA,Secureimage,WebSpamProtect,etc y con todos me pasa lo mismo.¿Cómo podría solucionar este problema? Gracias por la ayuda.


Título: Re: problema forumulario y captcha
Publicado por: Shell Root en 26 Agosto 2010, 22:07 pm
Si estás haciendo una petición POST, como quieres que funcione en GET. xD


Título: Re: problema forumulario y captcha
Publicado por: ~ Yoya ~ en 26 Agosto 2010, 22:10 pm
Si estás haciendo una petición POST, como quieres que funcione en GET. xD

Muy cierto xD
Código
  1. method="post">
  2.                    <p>
  3.                      <input type="hidden" name="id_noticia" value="<? $id = $_GET['id'];


Título: Re: problema forumulario y captcha
Publicado por: viher en 26 Agosto 2010, 22:14 pm
hago esto y tampoco funciona

Código
  1. <? $id = $_POST['id'];
  2.  echo "$id"; ?>


Título: Re: problema forumulario y captcha
Publicado por: ~ Yoya ~ en 26 Agosto 2010, 23:20 pm
recibes algún valor vía POST???
 Sabes lo que haces???


Título: Re: problema forumulario y captcha
Publicado por: viher en 26 Agosto 2010, 23:51 pm
claro que si,si el caso es que si quito el captcha y uso GET en el METHOD del formulario me publica los comentarios perfectamente,pero con POST no.


Título: Re: problema forumulario y captcha
Publicado por: Shell Root en 27 Agosto 2010, 00:12 am
Pero si usas el metodo POST, no existen un objeto llamado id. Intentad así:
Código
  1. <?PHP
  2.  $sNick = $_POST['nick']; # Donde 'nick' es el text
  3.  echo "$sNick";
  4. ?>

Sabes lo que haces???
claro que si,
jejejejejejejej es un sarcasmo verdad?


Título: Re: problema forumulario y captcha
Publicado por: viher en 27 Agosto 2010, 00:23 am
Pero si usas el metodo POST, no existen un objeto llamado id. Intentad así:
Código
  1. <?PHP
  2.  $sNick = $_POST['nick']; # Donde 'nick' es el text
  3.  echo "$sNick";
  4. ?>

Sabes lo que haces???
claro que si,
jejejejejejejej es un sarcasmo verdad?

shell root pero si el code que me has puesto es el mismo que puse yo arriba pero con otra variable diferente

hago esto y tampoco funciona

Código
  1. <? $id = $_POST['id'];
  2.  echo "$id"; ?>


Título: Re: problema forumulario y captcha
Publicado por: ~ Yoya ~ en 27 Agosto 2010, 00:23 am
Usa $_REQUEST, es la solución mas rápida que puedo darte... $_REQUEST acepta tanto GET como POST


Título: Re: problema forumulario y captcha
Publicado por: viher en 27 Agosto 2010, 00:25 am
ya probé usar $_REQUEST y tampoco  :-\


Título: Re: problema forumulario y captcha
Publicado por: ~ Yoya ~ en 27 Agosto 2010, 00:40 am
Ps ahora nose que decirte, si me dices que sabes lo que haces desde el principio al fin... No debes tener ningún problema.


Título: Re: problema forumulario y captcha
Publicado por: Shell Root en 27 Agosto 2010, 00:48 am
xD, porque no os pones el código que estais usando. Además de la CAPTCHA!


Título: Re: problema forumulario y captcha
Publicado por: viher en 27 Agosto 2010, 01:15 am
aqui el archivo principal donde aparece el form:

Código
  1. <?php
  2. $cryptinstall="./cryptographp.fct.php";
  3. include $cryptinstall;
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title><? include ("config.php");
  10. $id = $_GET['id'];
  11. $sql = "select * from videos where id=$id";
  12. //Instrucción a ejecutarse en la bbdd.
  13.  
  14. $squery = mysql_query($sql);
  15. //Ejecución de la instrucción
  16.  
  17. while($row = mysql_fetch_array($squery)){
  18. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  19. echo $row['nombre']; }
  20. ?></title>
  21. <meta name="description" content="<? include ("config.php");
  22. $id = $_GET['id'];
  23. $sql = "select * from videos where id=$id";
  24. //Instrucción a ejecutarse en la bbdd.
  25.  
  26. $squery = mysql_query($sql);
  27. //Ejecución de la instrucción
  28.  
  29. while($row = mysql_fetch_array($squery)){
  30. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  31. echo "Video ".$row['nombre']," - Categoría ".$row['cat']; }
  32. ?>" />
  33. <meta name="keywords" content="keywords." />
  34. <link rel="shortcut icon" href="http://www.web.com/fav.ico">
  35. <style type="text/css">
  36. body p strong {
  37. font-size: 36px;
  38. font-family:Arial, Helvetica, sans-serif;
  39. }
  40. body {
  41. background-color: #FCF;
  42. }
  43. body,td,th {
  44. color: #000;
  45. font-size: 12px;
  46. font-family: Verdana, Geneva, sans-serif;
  47. }
  48. a:link {
  49. color: #000;
  50. text-decoration: none;
  51. }
  52. a:visited {
  53. color: #000;
  54. text-decoration: none;
  55. }
  56. a:hover {
  57. color: #000;
  58. text-decoration: none;
  59. }
  60. a:active {
  61. color: #000;
  62. text-decoration: none;
  63. font-size: 16px;
  64. }
  65. </style>
  66. </head>
  67.  
  68. <body>
  69. <table width="100%" border="0">
  70.  <tr>
  71.    <td>      <table width="80%" border="0" align="center">
  72.      <tr>
  73.        <td width="48%"><table width="99%" border="0">
  74.          <tr>
  75.            <td><img src="images/1225769858906691038rg1024_o.png" alt="" width="385" height="73" border="0" usemap="#Map" />
  76.              <map name="Map" id="Map">
  77.                <area shape="rect" coords="5,3,377,69" href="index.php" />
  78.                </map></td>
  79.          </tr>
  80.        </table></td>
  81.        <td width="52%"><table width="99%" border="0">
  82.              <tr>
  83.                <td width="74%">&nbsp;</td>
  84.                <td width="26%" rowspan="2"><!-- AddThis Button BEGIN -->
  85.                <!-- AddThis Button END --><img src="images/cerdo.jpg" width="164" height="137" /></td>
  86.              </tr>
  87.            <tr>
  88.              <td><form id="form1" name="buscador" method="post" action="buscador.php">
  89.                  <p align="left"><b>Buscador de videos:</b><br>
  90.                    <input name="palabra" type="text" id="textfield" size="30"/>
  91.                    <input type="submit" name="button" id="button" value="Buscar" />
  92.                    </p>
  93.                  </p>
  94.                  </b>
  95.                  </form>
  96.              </font>&nbsp;</td>
  97.            </tr>
  98.          </table></td>
  99.      </tr>
  100.      <tr>
  101.        <td colspan="2" background="images/fondomenu.png" height="42"><table width="100%" border="0" height="44" bordercolor="#FF99FF">
  102.          <tr align="center" bordercolor="#FF99FF">
  103.            <td width="10%" onmouseover='this.style.background="#DB00AF"'  onmouseout='this.style.background=""'><a href="index.php"><font size="3">Inicio</font></a></td>
  104.            <td width="14%" onmouseover='this.style.background="#DB00AF"'  onmouseout='this.style.background=""'><font size="3"><a href="index.php?sección=categorias">Categorías</a></font></td>
  105.            <td width="13%" onmouseover='this.style.background="#DB00AF"'  onmouseout='this.style.background=""'><font size="3"><a href="index.php?sección=pornstars">Pornstars</a></font></td>
  106.            <td width="15%" onmouseover='this.style.background="#DB00AF"'  onmouseout='this.style.background=""'><a href="index.php?sección=espanolas"><font size="3">Españolas</font></a></td>
  107.            <td width="15%" onmouseover='this.style.background="#DB00AF"'  onmouseout='this.style.background=""'><font size="3"><a href="index.php?sección=top_50_videos_mas_vistos">Top videos</a></font></td>
  108.            <td width="19%" onmouseover='this.style.background="#DB00AF"'  onmouseout='this.style.background=""'><font size="3"><a href="index.php?sección=chat">Chat  (<?
  109. $archivo = "chat/online.txt";
  110. $lineas = count(file($archivo));
  111. echo "$lineas";
  112. ?>
  113.              online)</a></font></td>
  114.            <td width="14%" onmouseover='this.style.background="#DB00AF"'  onmouseout='this.style.background=""'><font size="3"><a href="enviar_video.php" target="_blank" onclick="window.open(this.href, this.target, 'width=600,height=400,scrollbars=yes' ); return false;">Enviar video</a></font></td>
  115.            </tr>
  116.          </table></td>
  117.      </tr>
  118.    </table>
  119.      <table width="80%" border="0" align="center">
  120.        <tr>
  121.          <td width="22%">&nbsp;</td>
  122.          <td width="18%">&nbsp;</td>
  123.          <td width="38%">&nbsp;</td>
  124.        </tr>
  125.        <tr>
  126.          <td height="30" colspan="3" background="images/cuadradofondo.png"><table width="100%" border="0">
  127.            <tr>
  128.              <td><table width="100%" border="0">
  129.                  <tr>
  130.                    <td><font size="3"><b>
  131.                      <? include ("config.php");
  132. $id = $_GET['id'];
  133. $sql = "select * from videos where id=$id";
  134. //Instrucción a ejecutarse en la bbdd.
  135.  
  136. $squery = mysql_query($sql);
  137. //Ejecución de la instrucción
  138.  
  139. while($row = mysql_fetch_array($squery)){
  140. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  141. echo "<b>".$row['nombre']."</b>"; }
  142. ?>
  143.                    </b></font></td>
  144.                    <td align="right"><a class="addthis_button" href="http://www.addthis.com/bookmark.php?v=250&amp;username=ccccc"><img src="http://s7.addthis.com/static/btn/v2/lg-share-en.gif" width="125" height="16" alt="Bookmark and Share" style="border:0"/></a>
  145.          <script type="text/javascript" src="http://s7.addthis.com/js/250/addthis_widget.js#username=ccccc"></script></font></a>&nbsp;</td>
  146.                  </tr>
  147.              </table></td>
  148.            </tr>
  149.          </table></td>
  150.        </tr>
  151.        <tr>
  152.          <td height="30" colspan="3" align="center"><table width="100%" border="0" align="center">
  153.  <tr align="center">
  154.    <td><table width="100%" border="0">
  155.      <tr>
  156.        <td align="center"></td>
  157.      </tr>
  158.    </table>
  159.      <table width="100%" border="0">
  160.        <tr>
  161.          <td width="68%" align="center"><p align="center"><? include ("config.php");
  162. $id = $_GET['id'];
  163. $sql = "select * from videos where id=$id";
  164. //Instrucción a ejecutarse en la bbdd.
  165.  
  166. $squery = mysql_query($sql);
  167. //Ejecución de la instrucción
  168.  
  169. while($row = mysql_fetch_array($squery)){
  170. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  171. $var = $row['embed']; }
  172. ?>
  173. <?
  174. $consulta="select * from videos where id=$id";
  175. $resultado=mysql_query($consulta) or die (mysql_error());
  176. if (mysql_num_rows($resultado) == 0)
  177. {
  178. echo "<script type='text/javascript'>
  179. window.location='http://www.web.com/404.html';
  180. </script>";
  181. }else{
  182. echo "$var";
  183. }
  184. ?></p>
  185.            <p align="center"><b>Duración:</b>
  186.              <? include ("config.php");
  187. $id = $_GET['id'];
  188. $sql = "select * from videos where id=$id";
  189. //Instrucción a ejecutarse en la bbdd.
  190.  
  191. $squery = mysql_query($sql);
  192. //Ejecución de la instrucción
  193.  
  194. while($row = mysql_fetch_array($squery)){
  195. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  196. echo $row['dur']; }
  197. ?>
  198.              | <b>Visualizaciones:</b>
  199.              <? include ("config.php");
  200. $id = $_GET['id'];
  201. $sql = "select * from videos where id=$id";
  202. //Instrucción a ejecutarse en la bbdd.
  203.  
  204. $squery = mysql_query($sql);
  205. //Ejecución de la instrucción
  206.  
  207. while($row = mysql_fetch_array($squery)){
  208. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  209. echo $row['vistas']; } ?>
  210.              <? include ("vistas.php"); ?>
  211.              | <b>Categoría:</b>
  212.              <? include ("config.php");
  213. $id = $_GET['id'];
  214. $sql = "select * from videos where id=$id";
  215. //Instrucción a ejecutarse en la bbdd.
  216.  
  217. $squery = mysql_query($sql);
  218. //Ejecución de la instrucción
  219.  
  220. while($row = mysql_fetch_array($squery)){
  221. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  222. echo $row['cat']; }
  223. ?>
  224.              | <b>Subcategoría:</b>
  225.              <? include ("config.php");
  226. $id = $_GET['id'];
  227. $sql = "select * from videos where id=$id";
  228. //Instrucción a ejecutarse en la bbdd.
  229.  
  230. $squery = mysql_query($sql);
  231. //Ejecución de la instrucción
  232.  
  233. while($row = mysql_fetch_array($squery)){
  234. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  235. echo $row['cat2']; }
  236. ?>
  237.            </p>
  238.            <p align="center"><a href="error.php" target="_blank" onclick="window.open(this.href, this.target, 'width=600,height=400,scrollbars=yes' ); return false;">¿El video no funciona? <b>Reportar error.</b></a></p>
  239.            <table width='76%' border='0'>
  240.              <tr>
  241.                <td width="62%" height='30' align="center" background='images/cuadradofondo.png'><b>Comentarios del video &quot;
  242.                  <? include ("config.php");
  243. $id = $_GET['id'];
  244. $sql = "select * from videos where id=$id";
  245. //Instrucción a ejecutarse en la bbdd.
  246.  
  247. $squery = mysql_query($sql);
  248. //Ejecución de la instrucción
  249.  
  250. while($row = mysql_fetch_array($squery)){
  251. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  252. echo $row['nombre']; }
  253. ?>
  254.                  &quot;</b></td>
  255.              </tr>
  256.              <tr>
  257.                <td bgcolor='#FFE1FF'><span style="font-size:11px;font-family:Tahoma;color:black;">
  258.                  <?
  259.  $id = $_GET['id'];
  260.      $resultComen = mysql_query("SELECT * FROM comentarios WHERE id_noticia='$id' ORDER BY id ASC");
  261.      while($rowComen = mysql_fetch_array($resultComen))
  262.      {
  263.      ?>
  264.                  <font color="RED"> <b><? echo "&nbsp;".$rowComen["nick"]; ?></b></font> <? echo $rowComen["comentario"]."<br>"; ?> <br />
  265.                  <?
  266.      }
  267.      mysql_free_result($resultComen);
  268.      ?>
  269.                  <center>
  270.                  <br />
  271.                 <form action="addcomentario.php"
  272.      method="post">
  273.                    <p>
  274.                      <input type="hidden" name="id_noticia" value="<? $id = $_POST['id'];
  275.  echo "$id"; ?>" />
  276.                      Nick :
  277.                      <label for="textfield"></label>
  278.                      <br />
  279.                      <input type="text" name="nick" size="20" maxlength="20" />
  280.                      <br />
  281.                      <br />
  282.                      Comentario:<br />
  283.                      <textarea name="comentario" cols="28" rows="6"></textarea>
  284.                      <br><table cellpadding=1>
  285.  <tr><td align="center"><?php dsp_crypt(0,1); ?></td></tr>
  286.  <tr><td align="center">Introduce el código:<br><input type="text" name="code"></td></tr>
  287. </table><br>
  288.                      <input type="submit" class="boton" value="Enviar" name="submit" />
  289.                    </p>
  290.                  </form>
  291.                  </p>
  292.                  </span></td>
  293.              </tr>
  294.            </table></td>
  295.          <td width="32%"><script  language="javascript"  type="text/javascript">iwsrcplus="http://codenew.impresionesweb.com/r/banner_iw.php?idrotador=68560&tamano=300x250&lgid="+((new Date()).getTime() % 2147483648) + Math.random(); document.write("<scr"+"ipt language=javascript  type=text/javascript src="+iwsrcplus+"></scr"+"ipt>");</script><noscript><iframe src="http://alt.impresionesweb.com/noscript.php?tam=300x250&idp=68560&ref=68560&cod=121215" width="300" height="250" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"></iframe></noscript><br><script  language="javascript"  type="text/javascript">iwsrcplus="http://codenew.impresionesweb.com/r/banner_iw.php?idrotador=68560&tamano=300x250&lgid="+((new Date()).getTime() % 2147483648) + Math.random(); document.write("<scr"+"ipt language=javascript  type=text/javascript src="+iwsrcplus+"></scr"+"ipt>");</script><noscript><iframe src="http://alt.impresionesweb.com/noscript.php?tam=300x250&idp=68560&ref=68560&cod=121214" width="300" height="250" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"></iframe></noscript><br><script  language="javascript"  type="text/javascript">iwsrcplus="http://codenew.impresionesweb.com/r/banner_iw.php?idrotador=68560&tamano=300x250&lgid="+((new Date()).getTime() % 2147483648) + Math.random(); document.write("<scr"+"ipt language=javascript  type=text/javascript src="+iwsrcplus+"></scr"+"ipt>");</script><noscript><iframe src="http://alt.impresionesweb.com/noscript.php?tam=300x250&idp=68560&ref=68560&cod=121214" width="300" height="250" frameborder="0" marginheight="0" marginwidth="0" scrolling="no"></iframe></noscript>
  296. </td>
  297.        </tr>
  298.      </table>
  299.      <p align="center">&nbsp;</p>
  300.      <CENTER>
  301.      </CENTER>
  302.     </td>
  303.  </tr>
  304. </table>
  305.            <table width="100%" border="0">
  306.              <tr>
  307.                <td align="center">      <h2>Videos relaccionados</h2>
  308.      </p><?
  309. include ("relaccionado.php");
  310. ?></p></td>
  311.              </tr>
  312.            </table>
  313.          <p>&nbsp;</p></td>
  314.        </tr>
  315.        <tr>
  316.          <td height="30" colspan="3" background="images/cuadradofondo.png"><font size="3"><b>&nbsp;Categorías</b> - Pincha en una categoría para ver los videos que contiene</font></td>
  317.        </tr>
  318.        <tr>
  319.          <td height="30" colspan="3" align="center"><br />            
  320.          <a href="index.php?sección=amateur">Amateur</a> - <a href="index.php?sección=anal">Anal</a> - <a href="index.php?sección=asiaticas">Asiáticas</a> - <a href="index.php?sección=mamadas">Mamadas</a> - <a href="index.php?sección=rubias">Rubias</a> - <a href="index.php?sección=morenas">Morenas</a> - <a href="index.php?sección=lesbianas">Lesbianas</a> - <a href="index.php?sección=orgias">Orgías</a> - <a href="index.php?sección=jovencitas">Jovencitas</a> - <a href="index.php?sección=maduritas">Maduritas</a> - <a href="index.php?sección=masturbacion">Masturbación</a> - <a href="index.php?sección=famosas">Famosas</a> - <a href="index.php?sección=interracial">Interracial</a> - <a href="index.php?sección=pornstars">Pornstars</a> - <a href="index.php?sección=espanolas">Españolas</a> - <a href="index.php?sección=pilladas">Pilladas</a>  - <a href="index.php?sección=squirting">Squirting</a> - <a href="index.php?sección=hardcore">Hardcore</a> - <a href="index.php?sección=otros">Otros</a><br /><br /></td>
  321.        </tr>
  322.        <tr>
  323.          <td height="10" colspan="3" align="center"><img src="images/lineafinal.png" width="800" height="2" /></td>
  324.        </tr>
  325.        <tr>
  326.          <td height="30" colspan="3" align="center"><p><a href="contacto.php" target="_blank" onClick="window.open(this.href, this.target, 'width=600,height=400,scrollbars=yes' ); return false;">Contacta con nosotros</a> | <a href="index.php?sección=aviso_legal">Aviso legal</a> | Copiright Tupixxx.com 2010</p>
  327.          <p><img src="images/badge_php.gif" width="80" height="15" />&nbsp;<img src="images/button-mysql.png.jpg" width="80" height="15" />&nbsp;<img src="images/css_powered.png" width="80" height="15" />&nbsp;<a href="sitemap.html"><img src="images/sitemap.jpg" width="80" height="15" border="0" /></a>&nbsp;<img src="images/firefox.gif" width="80" height="15" border="0" usemap="#Map2" />&nbsp;<a href=http://www.ademails.com/estadisticas1060002944.htm>
  328. <script type="text/javascript" language="javascript">
  329. <!--
  330. document.write("<img src=\"http://www.ademails.com/cgi-bin/contador.cgi?ID=1060002944");
  331. document.write("&referer=");
  332. document.write(escape(document.referrer));
  333. document.write("\" border=0 alt=\"Estadisticas\">");
  334. // -->
  335. </script><noscript><img src=http://www.ademails.com/cgi-bin/contador.cgi?ID=1060002944 alt="Estadisticas" height="15" border=0></noscript></p></td>
  336.        </tr>
  337.    </table></td>
  338.  </tr>
  339. </table>
  340. <map name="Map2" id="Map2">
  341.  <area shape="rect" coords="0,2,80,14" href="http://www.mozilla-europe.org/es/" target="_blank" />
  342. </map>
  343. </body>
  344. </html>

aqui addcomentario.php

Código
  1. <?php
  2. $cryptinstall="./cryptographp.fct.php";
  3. include $cryptinstall;
  4. ?>
  5. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  6. <html xmlns="http://www.w3.org/1999/xhtml">
  7. <head>
  8. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  9. <title>Documento sin título</title>
  10. </head>
  11.  
  12. <body><?php
  13. function Conectarse()
  14. {
  15.   if (!($link=mysql_connect("localhost","user","pass")))
  16.   {
  17.      echo "Error conectando a la base de datos.";
  18.      exit();
  19.   }
  20.   if (!mysql_select_db("db",$link))
  21.   {
  22.      echo "Error seleccionando la base de datos.";
  23.      exit();
  24.   }
  25.   return $link;
  26. }
  27.  
  28. $link=Conectarse();
  29.  
  30. mysql_close($link); //cierra la conexion
  31. ?> <?
  32. if (chk_crypt($_POST['code']))
  33.  {
  34.    $link=Conectarse();
  35.   $id_noticia=$_GET['id_noticia'];  
  36.   $nick=$_GET['nick'];
  37.   $comentario=$_GET['comentario'];
  38.   mysql_query("insert into comentarios (id_noticia,nick,comentario) values ('$id_noticia','$nick','$comentario')",$link);
  39.  echo "<center>Comentario publicado correctamente.</center><br>";
  40.  echo "<a href='video.php?id=$id_noticia'><center>Volver al video.</center></a><br>";
  41.     }else{
  42. echo "El código de seguridad que has introducido es incorrecto." ;
  43. }
  44. ?>
  45. </body>
  46. </html>


Título: Re: problema forumulario y captcha
Publicado por: Shell Root en 27 Agosto 2010, 01:27 am
xD, por Dios, que desorden de código. Y nisiquiera escapas las comillas. Por ejemplo aquí:
Código
  1. <meta name="description" content="<? include ("config.php");
  2. $id = $_GET['id'];
  3. $sql = "select * from videos where id=$id";
  4. //Instrucción a ejecutarse en la bbdd.
  5.  
  6. $squery = mysql_query($sql);
  7. //Ejecución de la instrucción
  8.  
  9. while($row = mysql_fetch_array($squery)){
  10. //Recuperar los datos de un registro o hilera (row) y meterlo a un array
  11. echo "Video ".$row['nombre']," - Categoría ".$row['cat']; }
  12. ?>" />

Debería ser así:
Código
  1. <?php
  2.  include ('config.php');
  3.  $id = $_GET['id'];
  4.  $sql = "SELECT * FROM videos WHERE id=".$id;
  5.  $squery = mysql_query($sql);
  6.  while($row = mysql_fetch_array($squery)){
  7.    $sReturn .= "Video ".$row['nombre']," - Categoría ".$row['cat'];
  8.  }
  9. ?>
  10. <meta name="description" content="<? echo $sReturn; >" />


Título: Re: problema forumulario y captcha
Publicado por: viher en 27 Agosto 2010, 01:57 am
gracias por el consejo shell root pero eso no resuelve mi problema  :-\


Título: Re: problema forumulario y captcha
Publicado por: Shell Root en 27 Agosto 2010, 02:35 am
Eso ya lo sé, te lo dije para que lo hicieras, esque queda muy dificil leer el código así como está.


Título: Re: problema forumulario y captcha
Publicado por: viher en 27 Agosto 2010, 23:32 pm
nadie me puede ayudar?  :-\


Título: Re: problema forumulario y captcha
Publicado por: ~ Yoya ~ en 27 Agosto 2010, 23:39 pm
No sabes lo que haces primeramente...
Código
  1. <form action="addcomentario.php"
  2.      method="post">
  3.                    <p>
  4.                      <input type="hidden" name="id_noticia" value="<? $id = $_POST['id'];
  5.  echo "$id"; ?>" />
  6.                      Nick :
  7.                      <label for="textfield"></label>
  8.                      <br />
  9.                      <input type="text" name="nick" size="20" maxlength="20" />
  10.                      <br />
  11.                      <br />
  12.                      Comentario:<br />
  13.                      <textarea name="comentario" cols="28" rows="6"></textarea>
  14.                      <br><table cellpadding=1>
  15.  <tr><td align="center"><?php dsp_crypt(0,1); ?></td></tr>
  16.  <tr><td align="center">Introduce el código:<br><input type="text" name="code"></td></tr>
  17. </table><br>
  18.                      <input type="submit" class="boton" value="Enviar" name="submit" />
  19.                    </p>
  20.                  </form>
Código
  1. <?
  2. if (chk_crypt($_POST['code']))
  3.  {
  4.    $link=Conectarse();
  5.   $id_noticia=$_GET['id_noticia'];  
  6.   $nick=$_GET['nick'];
  7.   $comentario=$_GET['comentario'];
  8.   mysql_query("insert into comentarios (id_noticia,nick,comentario) values ('$id_noticia','$nick','$comentario')",$link);
  9.  echo "<center>Comentario publicado correctamente.</center><br>";
  10.  echo "<a href='video.php?id=$id_noticia'><center>Volver al video.</center></a><br>";
  11.     }else{
  12. echo "El código de seguridad que has introducido es incorrecto." ;
  13. }
  14. ?>

El formulario se envía vía POST y le das los valores a la variable como si los datos vinieran vía GET y dices que sabes lo que haces xD.

Comprueba que los datos contengan valores, antes de procesar todo...
Código
  1. <form action="addcomentario.php"
  2.      method="post">
  3.                    <p>
  4.                      <input type="hidden" name="id_noticia" value="<? if(empty($_POST['id'])){exit;}$id = $_POST['id'];

Hacer lo mismo con esto:
Código
  1. <?
  2. if (chk_crypt($_POST['code']))
  3.  {
  4.    $link=Conectarse();
  5.   $id_noticia=$_GET['id_noticia'];  
  6.   $nick=$_GET['nick'];
  7.   $comentario=$_GET['comentario'];
  8.   mysql_query("insert into comentarios (id_noticia,nick,comentario) values ('$id_noticia','$nick','$comentario')",$link);
  9.  echo "<center>Comentario publicado correctamente.</center><br>";
  10.  echo "<a href='video.php?id=$id_noticia'><center>Volver al video.</center></a><br>";
  11.     }else{
  12. echo "El c&#38;#243;digo de seguridad que has introducido es incorrecto." ;
  13. }
  14. ?>
  15.  

Y para que sirve la función chk_crypt()???


Título: Re: problema forumulario y captcha
Publicado por: viher en 28 Agosto 2010, 00:15 am
hize lo siguiente:

addcomentario.php

Código
  1. <?
  2. if (chk_crypt($_POST['code']))
  3.  {
  4.    $link=Conectarse();
  5.   $id_noticia=$_POST['id_noticia'];  
  6.   $nick=$_POST['nick'];
  7.   $comentario=$_POST['comentario'];
  8.   mysql_query("insert into comentarios (id_noticia,nick,comentario) values ('$id_noticia','$nick','$comentario')",$link);
  9.  echo "<center>Comentario publicado correctamente.</center><br>";
  10.  echo "<a href='video.php?id=$id_noticia'><center>Volver al video.</center></a><br>";
  11.     }else{
  12. echo "El c&#38;#38;#243;digo de seguridad que has introducido es incorrecto." ;
  13. }
  14. ?>

la función chk_crypt() es del script del captcha

y en video.php

Código
  1. <form action="addcomentario.php"
  2.      method="post">
  3.                    <p>
  4.                      <input type="hidden" name="id_noticia" value="<? if(empty($_POST['id'])){exit;}$id = $_POST['id'];
  5.  echo "$id"; ?>" />
  6.                      Nick :
  7.                      <label for="textfield"></label>
  8.                      <br />
  9.                      <input type="text" name="nick" size="20" maxlength="20" />
  10.                      <br />
  11.                      <br />
  12.                      Comentario:<br />
  13.                      <textarea name="comentario" cols="28" rows="6"></textarea>
  14.                      <br><table cellpadding=1>
  15.  <tr><td align="center"><?php dsp_crypt(0,1); ?></td></tr>
  16.  <tr><td align="center">Introduce el código:<br><input type="text" name="code"></td></tr>
  17. </table><br>
  18.                      <input type="submit" class="boton" value="Enviar" name="submit" />
  19.                    </p>
  20.                  </form>

pero con este último código no me carga el formulario al ver la página.


Título: Re: problema forumulario y captcha
Publicado por: ~ Yoya ~ en 28 Agosto 2010, 00:21 am
No te carga porque el parámetro id que viaja vía POST no contiene ningún valor...

Pueda ser que seria vía GET, cambiarlo por esto:
Código
  1. <? if(empty($_GET['id'])){exit;}$id = $_GET['id']
Si no carga, es porque no recibes el parámetro id via GET y por lo tanto el captha tiende a fallar...


Título: Re: problema forumulario y captcha
Publicado por: viher en 28 Agosto 2010, 01:45 am
así es,ya funciona,muchas gracias YOYA  ;-)