PHP - Send to another client id page when you click on a cell

Asked

Viewed 901 times

1

I have a list of clients each in a cell.

I want, by clicking on the cell, send to another page the id of the selected client, safely. Without showing the id in the link.

Generating the tables:

$marcador = '<img src="../imagens/traco.png" width="5px" height="13px"> ';
//Iniciando tabela
        echo '<table>';
        //Mostrando em uma tabela
        foreach ($clientes as $cliente) {
            //Linha da tabela
            echo '<tr>';
            //Celula da tabela
            //Nome do cliente, recebe cor diferente
            echo '<td><a href="meuendereco/outrapagina"><span class="nome">' . $cliente->getNome() . '</span><br>'
            . $cliente->getFantasia() . '<br>'
            . $marcador . 'Cód.: ' . $cliente->get_id() . '<br>'
            . $marcador . $cliente->getEnderco() . ', ' . $cliente->getNum() . '<br>'
            . $marcador . $cliente->getBairro() . ' - ' . $cliente->getCidade() . ', ' . $cliente->getUf() . '</a></td>';
        }

Man CSS For my sake css I made a cell to be like a link.

@charset "utf-8";
/* CSS Document */

/* CORPO DA PÁGINA */
body {
	color:#666;		   /* cor padrão para todas fontes */
	font-weight: bold; 	/* negrito */
}

/********************* TABELA **********************************/
/* linha da tabela*/
table, td {
	padding-left: 15px;
	padding-top: 3mm;				  /* distancia do topo */
	padding-bottom: 1.5mm;			 /* distancia da base*/
	border-collapse: collapse;		 /* Borda simples */
	border-bottom: 1px solid green;	/* Borda de baixo */
	border-bottom-color: #666;		 /* cor da borda de baixo */
	
}
/* espaço da celula */
td:hover{
	background: #C6E2FF;	/*cor de fundo da celula*/			
	cursor: pointer;		/*cursor na celular será uma mãozinha*/
}
/* link na célula */
td a{
	text-decoration:none;   /* texto não ficará sumblinhado na tabela*/
	display: block;		 /* link será na célula */
	height: 100%;		   /* link será em toda célula*/ 
	color:#666;			 /* a cor do texto será (cinza)*/			
}
/******************* FIM - TABELA ******************************/

/* cor do nome dos clientes*/
.nome {
	font-size: 18px;		/* tamanho da fonte */
	color:#6699CC;		  /* cor da fonte */
	font-weight: bold;	  /* fonte em negrito */
}

  • On line 10 of the code you posted, pass the ID of the client by GET thus <a href="meuendereco/outrapagina?cliente_id=' . $cliente->get_id() . '">

  • Only this way the id is visible in the link. I want to avoid this. There is another way?

  • 3

    Actually this is not much problem no, because even sending by POST it is possible to view the data sent on request, but if it makes a big difference to you, use a form in each cell it is possible to send the id to the other page.

  • 1

    Why do you want to hide the customer ID? What is the threat you want to defend against?

  • You’re right, I don’t need to hide the client ID, but if I need to, I’ll make a form in the cell itself. Thank you.

1 answer

1


You can create a form in each cell and send each by POST the id customer’s

echo '<td><form action="meuendereco/outrapagina" style="display:none;" method="post" name="post_' . $cliente->get_id() . '" >
        <input type="hidden" name="client_id" value="' . $cliente->get_id() . '">
    </form>
    <a href="#" onclick="document.post_' .  $cliente->get_id() . '.submit();">' . $cliente->getNome() . '</span><br>'
            . $cliente->getFantasia() . '<br>'
            . $marcador . 'Cód.: ' . $cliente->get_id() . '<br>'
            . $marcador . $cliente->getEnderco() . ', ' . $cliente->getNum() . '<br>'
            . $marcador . $cliente->getBairro() . ' - ' . $cliente->getCidade() . ', ' . $cliente->getUf() . '</a></td>';
  • Foul htmlspecialchars around the customer data.

  • Where do you put the htmlspecialchars?

Browser other questions tagged

You are not signed in. Login or sign up in order to post.