Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $myServer = "localhost";
- $myUser = "myuser";
- $myPass = "password";
- $myDB = "testdb";
- //connection to the database
- $dbhandle = mysql_connect($myServer, $myUser, $myPass)
- or die("Couldn't connect to SQL Server on $myServer");
- //select a database to work with
- $selected = mysql_select_db($myDB, $dbhandle)
- or die("Couldn't open database $myDB");
- // The response variable
- $res = "res=KO";
- // Check incoming data
- if ($_POST['name'] != "" && $_POST['pass'] != "") {
- // Retrieve all rows from the "user_name" and "password" columns from the "account_info" table
- $result = mysql_query("SELECT user_name, password FROM account_info")
- or die(mysql_error());
- //create a loop that continues until each row is called
- while($row = mysql_fetch_array($result)) {
- //check if client user name/password is the same as the row from database
- if ($_POST['name'] == $row['user_name'] && $_POST['pass'] == $row['password']) {
- // If they match, Ok, user found
- $res = "res=OK";
- break;
- }
- }
- }
- print $res;
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement