One week ago, I set up a table in phpMyAdmin (localhost) and it contained student data and each student had their own ID. How can I create a page or form that asks the student to enter his unique ID to view his own data stored in this table without showing the rest of the students data, I have searched a lot and found no clear answer or explanation. .
----- In a simple way ----
First, the page contains a search box with a button (this user interface)
Second: After inter his ID and pressing this button, the table will be searched for information about this ID such as the student’s name, department and age.
How can I do that? I needed for my college.
thanks all

I covered most of these points? The form you have, can call a php file, which will query the database, and return a response

1 Like

look I’m a beginner in PHP and Mysql I want to build and complete my project I want to give it to my college for students … I’m so happy for your help but I want steps to complete it all I have in my PC is xampp by this software I set-up my first table in database (college) I want more information about .How can I input my ID in blank wep page for displayed my special information? can you be with me step by step to complete it ?

after press the search button he will see his data like name,age and department

this programming in notepad++ by HTML

i showed you how to set the action attribute on form element, if you set this action to a php script, in the php script you can connect to the database:

(this is for mysqli, you can also use PDO)

once the connection is established you can query the database:

but for security reasons you should really use prepared statements:

once you have the data, you just have to display it. Been a while since i done that without a template engine, but we will cross that bridge once we get there. This should keep you busy for a while

i think to start, you can just use echo if you want to display something, and var_dump()/dd() for debugging.

1 Like

I set up connection well with my data base by create a new php web page(in netbeans IDE) and copy code in ( to my php web page …
after that what ? How can user input his ID to this HTML page to get his results that saved in data base?

thanks for your help

you can’t just go about copying code and not wondering about what the code does. Have you checked the connection gets successfully established? I can’t hold your hand and walk you through each tiny step. As a programmer, you need to read, practice, think through these logic steps, validate they work

have you tried googling this? You can retrieve form data using $_POST, but surely there must a google query you can come up with find information about this matter, any ideas about a search query? Google is your friend

I linked to the docs about querying right? That should be a good first step, plus the where clause i already showed you in the other topic

I know a little information in PHP I have searched a lot in google for this idea but nothing works with my project
You are the first man to interact with me I have talked to a lot of people but there was nothing that helped me I’m glad to help you I need more research Nothing comes easy…

i can’t fix nothing works. Then i would need to be able to fiddle with the code, so i would have to set up a local copy of the project. Not sure that is included within my moderation duties

does the form submit to the action you set on the form?

did you include a die:

$mysqli = new mysqli("localhost", "user", "password", "database");
if ($mysqli->connect_errno) {
    echo "Failed to connect to MySQL: (" . $mysqli->connect_errno . ") " . $mysqli->connect_error;

like in the docs? Does the connection in fact die? Did you change the user, password and database to match your database?

If you can’t explain what isn’t working, i can’t help you with it. If you do not feel comfortable with everything that is happening, you might want to do some reading about php and databases in general, to understanding the architecture and flow

yeah I changed the user and password to matched my data base name (college)
and saved this work in index.php
my problem is what next ?

i have no idea what the code looks like, so i have no idea why that output i see in your screenshot is produced. What steps have happened

please provide more code and clarity and where you are. I don’t have access to the code like you do.

when i created a new file named index.php (in NetBeans IDE) and write this code for make a connected with my data base after changed the user and password to matched with my data base and run it i get this result in google chrome , also i tried to change data base base to other name to see what is happen and guess what the google chrome printed errors…

after run it the chrome print this result(last screenshot)

have you already created the PHP file which will handle the form submission? Is that going to be index.php? then set action attribute on form element accordingly.

1 Like

this my problem… after this work what I should do for get information from data base after reading ID (page programming in HTML- user interface-)

you have a form, with an input field and a submit button.

  1. if you press the submit button, the action (attribute of form) is triggered. If you set action attribute to a php file, this file is executed when form is submitted, so for example you want to run the code in index.php on form submission:
<form action="index.php" method="POST">
  1. then inside index.php you establish connection to the database (you have done this)

  2. then use $_POST to retrieve the value from the input field (within the index.php file). $_POST allows us to access data send along with the page, in this case data send by the form

  3. build the query with the retrieved form value.

Which of these steps does not make sense? Step 2 should make sense, you have done this

1 Like

I do it this was amazing I get the information of users by using ID
thank you soooooo much i’m grateful for your time to helped me
but do you know how I can upload all these on a web to be easy use it because now it’s on my local host?

publishing your application into production is a different story altogether. But before you do, you should really consider security. Given people could just attempt brute force attacks on id’s, there shouldn’t be any sensitive data.

1 Like

the information users not contain sensitive data like accounts or credit card or some thing like that he just has the name, age and department but the hackers can change all of these or even broke down my data base …
thank u for this advice I will work in this side and then publishing it

If the age, name and department data would be real, you still dealing with personal data, to which privacy policies exist. The rules may per country/union, but here in Europe the rules are pretty strict.

if i completed all of these how or where i publish my project ? to be used by users

you wouldn’t be ready, what about CSF protection?

there are so many ways to deploy PHP, there are so many hosting services (digital ocean, hostgator to name a few).

you would need: a domain, ssl (lets encrypt is free), apache (web server). Its quite a complicated process