How to get info from a database column through the GET method that I get from another page.

0

I'm new to php and database. I would like to know how to search the database for the "name", "password" "email" through the id I get via _GET from the previous page and display on the page that I am.

To make it clearer. I have a page where there is a table and in this table I have several columns and one of the columns is a link called details in which opens a page with more details of the same field. in the details link sending via _GET the id of my field. What I wanted was that when I opened the "details" page the new table would automatically have the information of the field selected on the previous page. Is there any code that through the received id can query the specific columns that were not shown and displayed on the new page?

Thanks for the help.

    
asked by anonymous 19.09.2014 / 02:10

2 answers

2

Dude,

I recommend you do not pass the concrete form id (site.php? id = 1).

Make it send in encrypted form, you can use the "base64_encode" at the time you insert the code in the link.Example:

<a href="bacon.php?id=<?php echo base64_encode([id]); ?>" />

Base64_encode Specification

This will generate a string in place of the id.

Now in the detail part, you can search the data with this query:

$sql = "SELECT [nome],[senha],[email] FROM [tabela] WHERE [id_automatico_da_coluna] = '".base64_decode($_GET[id])."'";
$query = mysqli_query($conexao,$sql);

Where you use base64_decode () to decode that string that came encrypted.

Base64_decode specification

    
19.09.2014 / 15:22
0

First you have to have a connection to the database, then just make the query and go through the returned records if they exist.

Take a look at these functions mysql_connect, mysql_query, mysql_fetch_assoc

PHP has good documentation in Portuguese. See here PHP Functions to use MYSQL

If your question concerns SQL would look like this:

SELECT nome, senha, email FROM tabela WHERE id = '$_GET['id']';

Are you in doubt about PHP or MySQL?

    
19.09.2014 / 02:23