elhacker.net cabecera Bienvenido(a), Visitante. Por favor Ingresar o Registrarse
¿Perdiste tu email de activación?.

 

 


Tema destacado: Curso de javascript por TickTack


+  Foro de elhacker.net
|-+  Programación
| |-+  Desarrollo Web
| | |-+  PHP (Moderador: #!drvy)
| | | |-+  ayuda con condigo php
0 Usuarios y 1 Visitante están viendo este tema.
Páginas: [1] Ir Abajo Respuesta Imprimir
Autor Tema: ayuda con condigo php  (Leído 2,411 veces)
Dannysoft


Desconectado Desconectado

Mensajes: 410


¡¡ Al Asalto !!


Ver Perfil
ayuda con condigo php
« en: 17 Noviembre 2008, 23:55 pm »

saludos foro tengo un problema he diseñado una pagina que muestra una informacion si introduces bien unos campos (cod_pro) y (contra), mi problema es este, quisiera que si se introducen ciertos numeros (26 por ejemplo) en el campo cod_pro me redireccione a una pagina x, y me muestre una info que esta en mi bd, el codigo que yo utilizo para mostra mi info es esta:

v_consulta.php

Código
  1. <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
  2. <html>
  3. <head>
  4. <title>:: Venser S.A.C. :::</title>
  5. <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
  6. <link href="estilo.css" rel="stylesheet" type="text/css">
  7. </head>
  8.  
  9. <body leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
  10. <table width="760" border="0" align="center" cellpadding="0" cellspacing="0">
  11.  <tr valign="top" bgcolor="#FFFFFF">  
  12.    <td colspan="3"><font color="#FFFFFF">  
  13.      <?php include("superior.htm")?>
  14.      </font></td>
  15.  </tr>
  16.  <tr valign="top" bgcolor="#FFFFFF">  
  17.    <td width="160"> <font color="#FFFFFF">  
  18.      <?php include("izquierda.htm")?>
  19.      </font></td>
  20.    <td width="440"><font color="#FFFFFF">&nbsp;
  21.  
  22.    <table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
  23.  <tr>
  24.    <td colspan="2"><table border="0" cellpadding="0" cellspacing="0" width="420">
  25.      <!-- fwtable fwsrc="titulo.png" fwbase="titulo.jpg" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
  26.      <tr>
  27.        <td><img src="images/spacer.gif" width="115" height="1" border="0" alt="" /></td>
  28.        <td><img src="images/spacer.gif" width="305" height="1" border="0" alt="" /></td>
  29.        <td><img src="images/spacer.gif" width="1" height="1" border="0" alt="" /></td>
  30.      </tr>
  31.      <tr>
  32.        <td rowspan="3"><img src="images/titulo_r1_c1.jpg" alt="" name="titulo_r1_c1" width="115" height="30" border="0" id="titulo_r1_c1" /></td>
  33.        <td><img src="images/titulo_r1_c2.jpg" alt="" name="titulo_r1_c2" width="305" height="2" border="0" id="titulo_r1_c2" /></td>
  34.        <td><img src="images/spacer.gif" width="1" height="2" border="0" alt="" /></td>
  35.      </tr>
  36.      <tr>
  37.        <td background="images/titulo_r2_c2.jpg" class="titulo">Preliquidaciones</td>
  38.        <td><img src="images/spacer.gif" width="1" height="25" border="0" alt="" /></td>
  39.      </tr>
  40.      <tr>
  41.        <td><img src="images/titulo_r3_c2.jpg" alt="" name="titulo_r3_c2" width="305" height="3" border="0" id="titulo_r3_c2" /></td>
  42.        <td><img src="images/spacer.gif" width="1" height="3" border="0" alt="" /></td>
  43.      </tr>
  44.    </table></td>
  45.  </tr>
  46.  <tr>
  47.    <td>&nbsp;</td>
  48.    <td>&nbsp;</td>
  49.  </tr>
  50.  <tr>
  51.    <td colspan="2" align="center" valign="middle" class="texto">RESULTADO DE LA CONSULTA</td>
  52.  </tr>
  53.  
  54.  <tr>
  55.    <td>&nbsp;</td>
  56.    <td>&nbsp;</td>
  57.  </tr>
  58.  <tr>
  59.    <td colspan="2"><?php  
  60.      require_once("autenticar_usr_fns.php");
  61. $postor=$_POST[cod_postor];//
  62. $contra=$_POST[contra];//'101'; //
  63.  
  64. $consulta_array=busca_empresa($postor,$contra);
  65.  
  66.  
  67. ?>
  68. <table width="100%" border="0" cellpadding="0" cellspacing="0" class="texto_nota">
  69.  <tr>
  70.    <td align="center" valign="middle" class="rojo">EL SALDO QUE FIGURA DEBERA DEPOSITARLO EN LA CTA/CTE ME</td>
  71.  </tr>
  72.    <tr>
  73.    <td align="center" valign="middle" class="rojo">DEL BANCO DE CREDITO DEL PERU Nº 193-1194690-1-84</td>
  74.  </tr>
  75.    <tr>
  76.    <td align="center" valign="middle" class="rojo">DE "LOS ANDES SERVICIOS CORPORATIVOS SAC"</td>
  77.  </tr>
  78. </table>  
  79.  <table class="alt1" width="100%" cellpadding=4 border=0 cellspacing=1>
  80. <?php
  81.  
  82.  if (!is_array($consulta_array)){
  83.     echo 'No Se Puede mostrar ningun dato(s) para esta Empresa o el código y contraseña no es correcto.<br>';
  84.       }
  85.  else{
  86.  $color = "#dfebf8";  
  87.  $alinea="center";
  88.  $alinea1="left";
  89.  $enca="class=thead";
  90.  
  91.  echo "<tr $enca> <td><strong>Nº</strong></td>";
  92.  echo "<td align=$alinea><strong>Postor</strong></td>";
  93.  echo "<td align=$alinea><strong>Lote</strong></td>";
  94.  echo "<td align=$alinea><strong>Base N°</strong></td>";
  95.  echo "<td align=$alinea><strong>SALDO A CANCELAR US$</strong></td>";
  96.  echo "</tr>";
  97.  
  98.      $aa=1;
  99.    $datofi=0;
  100.      foreach ($consulta_array as $cu)
  101.        {
  102.         foreach ($cu as $dato)
  103.           if ($color == '#dfebf8')
  104.            $color = '#f5f5f5';
  105.  
  106.          else
  107.          $color = '#dfebf8';
  108.  
  109.          echo "<tr bgcolor='$color'>";
  110.          echo "<td align='$alinea'>".$aa."\n</td>";
  111.          echo "<td align='$alinea'>".$cu[codigo]."\n</td>";
  112.          echo "<td align='$alinea'>".$cu[lote]."</td>";
  113.          echo "<td align='$alinea'>".$cu[codigo]."\n</td>";
  114.            echo "<td align='$alinea'>".$cu[saldo]."\n</td>";
  115.            echo "</tr>";
  116.           $aa++;
  117.           $datofi=$datofi+$cu[saldo];
  118.        }
  119.  
  120.  }
  121.  
  122. ?>
  123.  <tr class="alt5">
  124.    <td colspan="4" align="center">Saldo Total $ </td>
  125.    <td align="center"> <?php echo $datofi; ?> </td>
  126.  </tr>
  127. </table>
  128.  
  129. </td>
  130.    </tr>
  131.  <tr>
  132.    <td><a href="v_preliquidaciones.php">Regresar a consultar nuevamente</a></td>
  133.  
  134.  </tr>
  135. </table>
  136.      </td>
  137.    <td width="160"> <font color="#FFFFFF">  
  138.  
  139.  
  140.      <?php include("derecha.htm")?>
  141.      </font></td>
  142.  </tr>
  143.  <tr valign="top" bgcolor="#FFFFFF">  
  144.    <td colspan="3"><font color="#FFFFFF">&nbsp;
  145.      <?php include("base.htm")?>
  146.      </font></td>
  147.  </tr>
  148. </table>
  149. </body>
  150. </html>
  151.  
  152.  

mi codigo para autentificar
autenticar_usr_fns.php
Código
  1.  
  2. <?php
  3. //  
  4. require_once("conectardb_fns.php");
  5.  
  6. function busca_empresa($postor, $contra)
  7. {
  8. if (!$postor==' ')
  9.      return false;
  10.  
  11.  $conn = db_connect();
  12.  if (!$conn)
  13.    return false;
  14.  
  15.  $query = "select * from postores where codigo='$postor' and contra='$contra'";
  16.  
  17.      $result = @mysql_query($query);
  18.      if (!$result)
  19.     return false;
  20.    $num_proyectos = @mysql_num_rows($result);
  21.     if ($num_proyectos==0)
  22.         return false;
  23.         $result = db_resultados_array($result);
  24.       return $result;
  25. }
  26.  
  27. function db_resultados_array($resultado)
  28. {
  29.     $res_array = array();
  30.    for ($count=0; $row = @mysql_fetch_array($resultado); $count++)
  31.    $res_array[$count] = $row;
  32.    return $res_array;
  33. }
  34.  
  35.  
  36. ?>
  37.  

v_preliquidaciones.htm
Código:
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<title>Untitled Document</title>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">
<style type="text/css">
<!--
@import url("estilo.css");
-->
</style>
</head>

<body>
<table width="420" border="0" align="center" cellpadding="0" cellspacing="0">
  <tr>
    <td colspan="2"><table border="0" cellpadding="0" cellspacing="0" width="420">
        <!-- fwtable fwsrc="titulo.png" fwbase="titulo.jpg" fwstyle="Dreamweaver" fwdocid = "742308039" fwnested="0" -->
        <tr>
          <td><img src="images/spacer.gif" width="115" height="1" border="0" alt=""></td>
          <td><img src="images/spacer.gif" width="305" height="1" border="0" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="1" border="0" alt=""></td>
        </tr>
        <tr>
          <td rowspan="3"><img name="titulo_r1_c1" src="images/titulo_r1_c1.jpg" width="115" height="30" border="0" alt=""></td>
          <td><img name="titulo_r1_c2" src="images/titulo_r1_c2.jpg" width="305" height="2" border="0" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="2" border="0" alt=""></td>
        </tr>
        <tr>
          <td background="images/titulo_r2_c2.jpg" class="titulo">Preliquidaciones</td>
          <td><img src="images/spacer.gif" width="1" height="25" border="0" alt=""></td>
        </tr>
        <tr>
          <td><img name="titulo_r3_c2" src="images/titulo_r3_c2.jpg" width="305" height="3" border="0" alt=""></td>
          <td><img src="images/spacer.gif" width="1" height="3" border="0" alt=""></td>
        </tr>
      </table></td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" class="texto">Introduce tu Nro de Postor y Fact./Boleta</td>
  </tr>
  <tr>
    <td colspan="2" class="texto">&nbsp;</td>
  </tr>
  <tr>
    <td colspan="2" class="texto">&nbsp;</td>
  </tr>
  <tr valign="top">
    <td colspan="2" align="center" class="texto"><form name="form1" method="post" action="v_consulta.php">
        <table width="100%" border="1" align="center" cellpadding="0" cellspacing="0" bordercolor="#990002">
        <tr>
          <td><table border="0" align="center" cellpadding="0" cellspacing="8">
              <tr>
                <td width="200" align="right" valign="middle" class="texto"><div align="right"><strong>Numero de postor:</strong></div></td>
                <td width="200"><input type="text" name="cod_postor" id="cod_postor"></td>
              </tr>
              <tr>
                <td align="right" valign="middle" class="textoderecha"><div align="right">Contrase&ntilde;a :</div></td>
                <td class="texto"><input type="password" name="contra" id="textfield"></td>
              </tr>
              <tr>
                <td class="texto">&nbsp;</td>
                <td class="texto"><input type="submit" name="button" id="button" value="Consutar"></td>
              </tr>
          </table></td>
        </tr>
      </table>
        </form>      </td>
  </tr>
  <tr>
    <td>&nbsp;</td>
    <td>&nbsp;</td>
  </tr>
</table>
</body>
</html>

mi problema es como puedo hacer eso ?, gracias por la ayuda que me den...


« Última modificación: 17 Noviembre 2008, 23:58 pm por Dannysoft » En línea

No hay perfeccion sin esfuerzo...
willyhunting

Desconectado Desconectado

Mensajes: 72



Ver Perfil WWW
Re: ayuda con condigo php
« Respuesta #1 en: 18 Noviembre 2008, 00:31 am »

Jo Dannysoft, te explicas como un libro abierto. ¿Qué es exactamente lo que quieres hacer?

Primero deberías explicar lo que tienes, y no poner el código a lo bestia, porque la gente perra como yo no nos solemos poner a descifrarlo.

Una vez queda claro lo que tienes, es cuando debes plantear lo que quieres de la forma más concisa posible.

Además, deberías cuidar un poco los signos de puntuación y no escribir a lo loco. Escribir no es hablar; y esto es un foro, no el messenger. Creo que todos salimos ganando si escribimos bien.

En cuanto al código que has puesto, yo te aconsejaría separar php de html lo máximo posible. Es decir, separar presentación de contenido. Así es más fácil de leer y de mantener. Sino es un caos.

Ahora, voy a intentar ayudarte. Me ha dado la impresión que el problema es que no sabes redireccionar en php. Busca la función header a ver qué te parece.


En línea

Dannysoft


Desconectado Desconectado

Mensajes: 410


¡¡ Al Asalto !!


Ver Perfil
Re: ayuda con condigo php
« Respuesta #2 en: 18 Noviembre 2008, 06:10 am »

saludos aver, disculpa por el desorden del codigo paso a eplicar mas o menos lo que deseo hacer con ese codigo, bueno lo que quiero hacer es esto en el campo cod_postor que esta en la pagina v_preliquidaciones.htm si alguien ingresa por ejemplo 26 o 129 que se redireccione a otra pagina (por ejemplo v_consulta2.php), como haria eso con php?
En línea

No hay perfeccion sin esfuerzo...
willyhunting

Desconectado Desconectado

Mensajes: 72



Ver Perfil WWW
Re: ayuda con condigo php
« Respuesta #3 en: 18 Noviembre 2008, 11:07 am »

Eso es muy fácil. Mírate la función header y como redireccionar en php. Es lo que te he comentado antes.
En línea

Dannysoft


Desconectado Desconectado

Mensajes: 410


¡¡ Al Asalto !!


Ver Perfil
Re: ayuda con condigo php
« Respuesta #4 en: 18 Noviembre 2008, 12:33 pm »

disculpa willyhunting podrias ponerme un ejemplo de lo que me acabas de decir ?
En línea

No hay perfeccion sin esfuerzo...
Novlucker
Ninja y
Colaborador
***
Desconectado Desconectado

Mensajes: 10.683

Yo que tu lo pienso dos veces


Ver Perfil
Re: ayuda con condigo php
« Respuesta #5 en: 18 Noviembre 2008, 12:37 pm »

Ya te lo han dicho!!! busca sobre la función header, no intentes que te den todo hecho, intenta informarte  :¬¬

Código
  1. <?php
  2. header ("Location: http://www.google.com");
  3. ?>
El resto lo consigues con un IF, supongo que sabrás como hacer eso  :rolleyes:

Saludos
En línea

Contribuye con la limpieza del foro, reporta los "casos perdidos" a un MOD XD
"Hay dos cosas infinitas: el Universo y la estupidez  humana. Y de la primera no estoy muy seguro."
Albert Einstein
willyhunting

Desconectado Desconectado

Mensajes: 72



Ver Perfil WWW
Re: ayuda con condigo php
« Respuesta #6 en: 18 Noviembre 2008, 12:55 pm »

Novlucker, me has quitado las palabras de la boca.

Dannysoft, en un foro en el que supuestamente hay hackers o gente que aspira a serlo (newbies), no deberías esperar que te lo den todo hecho. Aquí se valora tanto al que guía, como al que a partir de la guía se busca la vida investigando, que al fin y al cabo, es lo que le gusta a un hacker.   :o

Si esperas respuestas directas, quizá no recibas ninguna.
En línea

Páginas: [1] Ir Arriba Respuesta Imprimir 

Ir a:  

Mensajes similares
Asunto Iniciado por Respuestas Vistas Último mensaje
Ayuda con condigo
Java
Erick9536 1 1,679 Último mensaje 8 Abril 2012, 15:50 pm
por Proteus1989
Ayuda con Pirámide en condigo C
Programación C/C++
rafa_rdj 3 4,351 Último mensaje 29 Abril 2015, 03:59 am
por engel lex
Problema con condigo If Exist y For « 1 2 »
Scripting
xBart 15 8,441 Último mensaje 13 Noviembre 2017, 04:17 am
por xBart
WAP2 - Aviso Legal - Powered by SMF 1.1.21 | SMF © 2006-2008, Simple Machines