Foros del Web » Programando para Internet » PHP »

No entra en un bucle

Estas en el tema de No entra en un bucle en el foro de PHP en Foros del Web. Hola chic@s,antes de nada,gracias por vuestra atencion!! Mi problema es que tengo una pagina web en PHP en la que tengo que ir annadiendo nuevas ...
  #1 (permalink)  
Antiguo 16/11/2009, 02:57
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
No entra en un bucle

Hola chic@s,antes de nada,gracias por vuestra atencion!!

Mi problema es que tengo una pagina web en PHP en la que tengo que ir annadiendo nuevas funcionalidades,en este caso que el usuario de la pagina pueda buscar clientes que estan en la base de datos,y que te muestre la informacion sobre ellos,el problema que tengo(uno de ellos) es que en mi archivo search_customer.php que ahora pondre a continuacion no me entra en el if que esta marcado y claro cuando luego usas el formulario y presionas 'search' no hace nada..alguna idea de porque no entra en el if?creo que los botones estan bien definidos,alomejor algo de la cabecera de como meto la informacion via post o algo asi???


<?
session_start();

require_once('class.FastTemplate.php4');
require_once('connection_data.php');
require_once('mysql_func.php');

require_once('insertFunc.php');

require_once('editFunc.php');


require_once('class.rc4crypt.php');

require_once('crypt.inc.php');

require_once('search_func.php');


//------------------------------ main -------------------------------------

$ret = 2;


//get the information via http post

$search = $HTTP_POST_VARS['Search'];


//initialize the fast templates

$tpl = new FastTemplate(".");

$tpl->define(array("main" => "templates/search.tpl"));

$tpl->assign(SCRIPT,$PHP_SELF);

$tpl->assign(NAME, "Search");


//-------------------------------------------------------------------------------------------------------------------

if ($search == 'Search') aqui no me entra..

{

$ret = checkSmallValues($tpl);

}


else resetValues_search($tpl);


if ($ret==0)

{

//insert values in show_search.ptl

//$tpl->define(array("main" => "templates/show_search.tpl"));---esto no se si es asi para ir a la otra pagina

//showInformation("templates/show_search.tpl");

confirmInsertion_2("templates/show_search.tpl");

//reset values

reset($HTTP_POST_VARS);

$ret = 2;

$insert = "";


exit();

}
else if ($ret==1)


{
$tpl->assign(NAME, "<FONT COLOR=\"red\"> Warning Field tu padre</FONT>");

}


$tpl->assign(BUTTONS, '<input class="buttons" type = "submit" value="Search" color=blue name="Search">');

//display the template

$tpl->parse(result, "main");

$tpl->FastPrint(result);

?>


muchas gracias
  #2 (permalink)  
Antiguo 16/11/2009, 05:48
Avatar de .php  
Fecha de Ingreso: julio-2006
Mensajes: 481
Antigüedad: 17 años, 8 meses
Puntos: 5
Respuesta: No entra en un bucle

mmmmm,
estas cosas hay que analisar por q no funciona.
primero que es esto

$search = $HTTP_POST_VARS['Search'];

imaginamos que $HTTP_POST_VARS['Search'] un txt y tiene un value que diga hola; entonces
$search = 'HOLA';

ahora que tipo de comparacion haces.

if ($search == 'Search') // es lo mismo que decir: si 'HOLA' es igual a 'Search'

estas comparando 2 string,

ahora el problema es ¿que es search?
un textbox o un boton.
no puedo ser adivino, que tengas suerte.
__________________
~~[FiDeLio]~~
  #3 (permalink)  
Antiguo 16/11/2009, 06:05
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: No entra en un bucle

tienes razon teng que ser mas especifico,soy novato
es un boton,significa que cuando presione un boton 'search' haga lo que esta dentro del if
  #4 (permalink)  
Antiguo 16/11/2009, 06:08
Avatar de gjx2  
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: No entra en un bucle

Lo primero que te recomiendo es que verifiques que estas mandando

por
Código PHP:
Ver original
  1. $search = $HTTP_POST_VARS['Search'];
  2.  
  3. echo $search;

Y si quieres confirmar que se presiono el boton search la manera seria .


Código PHP:
Ver original
  1. if(isset($_POST['Search'])){
  2. ..........
  3. }
  #5 (permalink)  
Antiguo 16/11/2009, 06:13
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
voy probando a ver gracias

lo he probado las dos cosas y no me muestra nada por pantalla..

Última edición por GatorV; 16/11/2009 a las 10:23
  #6 (permalink)  
Antiguo 16/11/2009, 06:44
Avatar de .php  
Fecha de Ingreso: julio-2006
Mensajes: 481
Antigüedad: 17 años, 8 meses
Puntos: 5
Respuesta: No entra en un bucle

cambia la condicion

Código PHP:
if(!empty($_POST['Search'])){
//CODE

__________________
~~[FiDeLio]~~
  #7 (permalink)  
Antiguo 16/11/2009, 06:48
Avatar de gjx2  
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: No entra en un bucle

Cita:
Iniciado por edugilc Ver Mensaje
lo he probado las dos cosas y no me muestra nada por pantalla..
Claro si no te funciona

Código php:
Ver original
  1. $search = $HTTP_POST_VARS['Search'];
  2.  
  3. echo $search;

Es por que no estas haciendo uso correcto del formulario.

Muestra el codigo del formulario que utilizas.
  #8 (permalink)  
Antiguo 16/11/2009, 07:46
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: No entra en un bucle

este es el codigo html del formulario:


<html><head>

<title>Search</title>

<link href="templates/style/buttons.css" type=text/css rel=stylesheet>

<link href="templates/style/W3C-REC.css" type=text/css rel=stylesheet>



<script language="JavaScript" type="text/javascript">


var bV=parseInt(navigator.appVersion);

NS4=(document.layers)&&(bV>=4) ? true : false;

IE4=((document.all)&&(bV>=4)) ? true : false;

DOM= (!document.layers && !document.all && bV>=4) ? true : false; // A hack to guess if the browser supports the DOM

capable = (NS4 || IE4 || DOM) ? true : false;

function expandIt(){return;}



</script>



</head>

<body {color} background="images/topBG2.png">



<script language="JavaScript" type="text/javascript" src="templates/FX.js">



alert("Error, It Can't Load JavaScript LIBRARY");


</script>


<script>


function recall(form,control)
{

//dir = "select_customer.php?letter="+document.forms[0].elements['letter'].value;

// alert(control);

window.location.href = "search_customer.php?country_html="+document.f orms[0].elements['country_html'].value+"&companylist_html="+document.forms[0].elements['companylist_html'].value;

}

//********************* aqui e puesto search_customer porq yendo hacia selectcustomer3 es lioso *************


</script>


<p align=LEFT>

<table width = 535 height="1" bordercolor="#000080" border="0">

<tr>

<td align = left width="33" valign="top" height="40" bgcolor="#000080">

&nbsp;

</td>

<td align = left width="637" valign="top" height="40" bgcolor="#000080">

<h1>{NAME} Customer</h1></font>

</td>

</tr>

<tr>

<td align = left width="33" valign="top" height="1">

</td>

<td align = left width="637" valign="top" height="1">

</td>

</tr>

<tr>

<td align = left width="33" valign="top" height="13" bgcolor="#000099">

&nbsp;

</td>

<td align = left width="637" valign="top" height="13" bgcolor="#000099">

<font color="#FFFFFF" face="Arial Black">Please enter the information about the Customer you

wish to find</font>

</td>

</tr>

<tr>

<td align = left width="33" valign="top" height="1">

</td>

<td align = left width="637" valign="top" height="1">

</td>

</tr>

<tr>

<td align = left width="33" valign="top" height="1">

</td>

<td align = left width="637" valign="top" height="1">

</td>

</tr>



</table>



<br>

<form method="GET" action="{SCRIPT}">



<table width = 535 height="1" bordercolor="#000080" border="0">



<tr>

<td width="20" valign="bottom">

<table>

<tr>

<td>

<td width="30%"><font color=black color=white face="Times New Roman, Times, serif"><B>First name</B>
<input type = "text" name = "customer_name_html" style="width:200px" value="" size = "24" maxlength="255">

</select>

<br>
<font color=black color=white face="Times New Roman, Times, serif"><B> Last name</B>
<input type = "text" name = "customer_name_html" style="width:200px" value="" size = "24" maxlength="255">

</select>
<br>
<font> <B>Country</B></font> <br>

<select name="country_html" style="width:200px" size="1" onchange=recall(this.form,"country")>

{COUNTRY}

</select>

<font><B>Company List</B> </font><br>

<select name="companylist_html" style="width:200px" size="1" onchange=recall(this.form,"companylist")>

{COMPANYLIST}
</select>
</td>

</tr>


</table>

<td width="50" valign="bottom">

<table heigth="10">



<font><B> Customers List</B></font><br>

<select name=id style="width:265px" size="5">



{TABLE_ROW}



</select>

</td>

<td width ="30" align="center" valign="bottom">

{BUTTONS}

</td>

</table>

</td>

</tr>

</table>

</form>




</body>
</html>
*************************************************
*************************************************
y este es mi codigo php en el archivo search_customer.php
*************************************************
*************************************************
session_start();

require_once('class.FastTemplate.php4');
require_once('connection_data.php');
require_once('mysql_func.php');

require_once('insertFunc.php');

require_once('editFunc.php');


require_once('class.rc4crypt.php');

require_once('crypt.inc.php');

require_once('search_func.php');


//------------------------------ main -------------------------------------



$ret = 2;



//get the information via http post

echo $search;

$search = $HTTP_POST_VARS[Search];




//initialize the fast templates



$tpl = new FastTemplate(".");

$tpl->define(array("main" => "templates/search.tpl"));

$tpl->assign(SCRIPT,$PHP_SELF);

$tpl->assign(NAME, "Search");




country_select($tpl,$country_html); //*** funcion de insertFunc.php ***//

company_select($tpl,$companylist_html); //*** funcion de editFunc.php ***//
getSelectValue_3($tpl,"search_customer.php",$lette r); //*** funcion de editFunc.php ***//



//-------------------------------------------------------------------------------------------------------------------

if ($search == 'Search') //'si presiono el boton search'

{


$ret = checkSmallValues($tpl);



else resetValues_search($tpl);


if ($ret==0)

{




?>

<script>



function redir(){

window.location.href = "select_customer3.php"

}


redir();



</script>

<?php



//insert values in show_search.ptl

$tpl->define(array("main" => "templates/show_search.tpl"));//

showInformation("templates/show_search.tpl");


confirmInsertion_2("templates/show_search.tpl");

//reset values

reset($HTTP_POST_VARS);

$ret = 2;

$insert = "";


exit();

}
else if ($ret==1)


{
$tpl->assign(NAME, "<FONT COLOR=\"red\"> Warning Field </FONT>");

}


$tpl->assign(BUTTONS, '<input class="buttons" type = "submit" value="Search" color=blue name="Search">');

//display the template

$tpl->parse(result, "main");

$tpl->FastPrint(result);
  #9 (permalink)  
Antiguo 16/11/2009, 08:06
Avatar de gjx2  
Fecha de Ingreso: agosto-2008
Ubicación: R.D
Mensajes: 1.153
Antigüedad: 15 años, 8 meses
Puntos: 139
Respuesta: No entra en un bucle

1- Estas enviando variables por GET y la estas recibiendo por POST

deveria enviarla de esta forma

Código HTML:
Ver original
  1. <form method="POST" action="{SCRIPT}">
  #10 (permalink)  
Antiguo 16/11/2009, 11:47
 
Fecha de Ingreso: octubre-2009
Mensajes: 154
Antigüedad: 14 años, 6 meses
Puntos: 0
Respuesta: No entra en un bucle

ya lo he cambiado y ahora si que entra en el if,si que era eso pero me sale el mensaje 'post variables not set' que es un messaje de error dentro de una funcion llamada 'checksmallValues' que comrueba si has metido algun valor y sino se repite con alguno introducido ya antes en la base de datos pero,ahora meta o no meta datos me sale ese error...

************************************************** ********************************

function checkSmallValues(&$tpl)
{
global $HTTP_POST_VARS;

//reset values to the fasttemplate
$tpl->assign(FIRSTNAME, "");
$tpl->assign(LASTNAME, "");
$tpl->assign(COUNTRY_1, "");
$tpl->assign(COMPANYLIST, "");

country_select($tpl,$country);
company_select($tpl,$companylist);

$search="";

//post variables set?

if (!isset($HTTP_POST_VARS[firstname_html]) ||
!isset($HTTP_POST_VARS[lastname_html]))

{
echo "Post variables not set";
die;
}

$firstname = trim($HTTP_POST_VARS["firstname_html"]);
$lastname = trim($HTTP_POST_VARS["lastname_html"]);
$country = $HTTP_POST_VARS["country_html"];
$companylist = $HTTP_POST_VARS["companylist_html"];

///////write values to the FastTemplate

$tpl->assign(FIRST_VALUE, $firstname);
$tpl->assign(LAST_VALUE, $lastname);


country_select($tpl,$country);
company_select($tpl,$companylist);

$tpl->assign(NAME, "<FONT COLOR=\"red\">Error </FONT>");

//////check for empty values

if ($firstname == "")
{

$tpl->assign(FIRST, '<FONT SIZE="1" COLOR="red"> **missing Customer Name** </FONT>');
return(1);
}
if ($lastname == "")
{
$tpl->assign(LAST, '<FONT SIZE="1" COLOR="red"> **missing Customer Name** </FONT>');
return(1);
}


//estaria bien que comprobara si esta el nombre pero aqui tengo el nombre como una variable y en esta funcion el apellido y el nombre son dos cosas diferentes..


if (check*****istingFirstnameAndLastname ($tpl,$firstname,$lastname))
{
return (1);
}

}
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 03:16.