How to get info from one column of the database via the GET method I receive from another page.

Asked

Viewed 1,317 times

0

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

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 link send details via _GET the id of my field. What I wanted was that when I opened the "details" page the new table was automatically with the information of the selected field on the previous page. Is there any code that through the received id can query the specific columns that before did not show and display on the new page?

thanks for the help.

  • 1

    It’s not very clear what you want. It helps a lot if you include the code of what you’ve done so far (just what’s relevant to the question).

  • It would be nice to ask exactly the stage that is doubtful, because the way it is has a lot of unknowns, and seems to me to have more of a problem in the same question. Suggested reading, to increase the chance of getting good answers in Stack Overflow: [Ask]

2 answers

2

Dude,

I recommend you do not give the id concretely (site.php? id=1).

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

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

Specification of base64_encode

This way will generate a string instead of id.

Already 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 here you use base64_decode(), to decode that string that came encrypted.

Specification of base64_decode

  • 2

    "encrypted" (between quotation marks)

  • 2

    is kk. It’s not really an encryption, but it’s just the way to talk. :)

  • 2

    Not encrypted but encrypted, bringing extra security to the application. Base64 is a two-way encryption where you can return existing information other than MD5 which is a one-way encryption. So @Christianpassold is correct when speaking in cryptography already Andrey needs to study a little more, we should not satirize something that is correct maybe without the due knowledge.

  • 1

    I understand that there is a good intention to post an answer, but I believe that the content does not answer the question of fact, and I do not see where Base64 helps in these cases, first for being the simplest thing to decode online, second for being visually easy to identify the encoding.

0

First you have to have a connection to the database, then just do 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 English. See here PHP functions to use MYSQL

If your doubt concerns SQL would be so:

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

You are in doubt in PHP or Mysql?

  • 2

    The first version of the answer had more to do with what is being asked. And remember Bobby: http://xkcd.com/327/

  • 1

    I did not understand if his doubt is with PHP or Mysql

  • Mysql, I’ll search the link you sent me. thanks

  • 2

    If you can not solve, edit your question and put what you have, that will help us help you. kkk Hug

Browser other questions tagged

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