Jump to content

HTML, MySQL, PHP, Database Check Help

Hey guys,

 

I am hoping you can help me out! I am new to MySQL and PHP (still learning), and I am trying to figure out a way to incorporate a simple "check" system in my test website to allow the user to go to a section in the website if the value they entered within the "check" field is a value in the MySQL database. I can picture how I need to do it in Java (I am pretty fluent in that), but using this is mind boggling to me.

 

Let me explain it a little bit better. My goal is to have select people given one unique number (4394 for an example), and once they go into a special page on my website, they are given the opportunity to type in the number they are given, sort of like a password. If the value they wrote is in the MySQL database, then they are granted access to the next page. If not, they are brought to a failed page (can literally be anything). The reason I need it to be a database is because the goal is to give many people (1000+) a special number unique to them, while giving me the opportunity to easily add additional numbers for new people.

 

In Java, I would do this through an array which has the values saved as strings in each element, then once the user inputs their number, it would traverse the array and run a simple if statement. If the user input value is equal to a string within an element of the array, then it will break the loop and bring the user to another page. If the user input is not equal to a string within the array, then it would just say "Error". Like I said, I am incredibly new to all of this, so this may very well be the way of doing in MySQL and PHP, but I have no clue.

 

Thanks for any help you can give me!

CPU: Intel Core i5 3570k GPU: Zotac Geforce GTX 560  Memory: 8GB DDR3 1866mhz  Storage: 1TB Seagate 7200rpm Internal, 2TB RAID 10 External  MOBO: Asus P8Z77-V


CPU: Intel Core i5 4550 GPU:  MSI Gefroce GTX 760  Memory: 16GB DDR3 1600mhz Storage: 1TB Westen Digital 7200rpm, 128GB SSD  MOBO: Gigabyte Model


Refurbished (by me :D) Alienware m17xr3 with CPU: Intel Core i7 2600k GPU: AMD Radeon 6870m   Memory: 16GB DDR3 1600mhz  Storage: 1TB  Western Digital 7200rpm

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, brcdncn said:

Will do! Thanks for the reply!

CPU: Intel Core i5 3570k GPU: Zotac Geforce GTX 560  Memory: 8GB DDR3 1866mhz  Storage: 1TB Seagate 7200rpm Internal, 2TB RAID 10 External  MOBO: Asus P8Z77-V


CPU: Intel Core i5 4550 GPU:  MSI Gefroce GTX 760  Memory: 16GB DDR3 1600mhz Storage: 1TB Westen Digital 7200rpm, 128GB SSD  MOBO: Gigabyte Model


Refurbished (by me :D) Alienware m17xr3 with CPU: Intel Core i7 2600k GPU: AMD Radeon 6870m   Memory: 16GB DDR3 1600mhz  Storage: 1TB  Western Digital 7200rpm

Link to comment
Share on other sites

Link to post
Share on other sites

You could do

SELECT * FROM `table` WHERE `pin` = $pin

$pin being the number submit in the form, so probably $_POST['pin']
and if the number of rows returned is greater than 0, the pin was in the table at least once. http://php.net/manual/en/pdostatement.rowcount.php


 

ps: Make sure you used prepared statements and clean user input.

Link to comment
Share on other sites

Link to post
Share on other sites

1 hour ago, prolemur said:

You could do


SELECT * FROM `table` WHERE `pin` = $pin

$pin being the number submit in the form, so probably $_POST['pin']
and if the number of rows returned is greater than 0, the pin was in the table at least once. http://php.net/manual/en/pdostatement.rowcount.php


 

ps: Make sure you used prepared statements and clean user input.

would suggest PDO. Also pin would be the identifier and therefore be unique so there should only be one.

 

                     ¸„»°'´¸„»°'´ Vorticalbox `'°«„¸`'°«„¸
`'°«„¸¸„»°'´¸„»°'´`'°«„¸Scientia Potentia est  ¸„»°'´`'°«„¸`'°«„¸¸„»°'´

Link to comment
Share on other sites

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×