Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $host="localhost"; // Host name
- $username="test"; // Mysql username
- $password="pocakaj"; // Mysql password
- $db_name="game"; // Database name
- $tbl_name="game"; // Table name
- // Connect to server and select databse.
- $connection = new mysqli($host, $username, $password, $db_name);
- $myusername=$_POST['myusername'];
- $mypassword=$_POST['mypassword'];
- //Should really just turn off magic quotes
- $myusername = stripslashes($myusername);
- $mypassword = stripslashes($mypassword);
- $query = "SELECT password FROM $tbl_name WHERE username=?";
- $stmt = $connection->prepare($query);
- $stmt->bind_param('s', $myusername);
- $stmt->execute();
- $stmt->bind_result($password);
- $stmt->fetch();
- if($stmt->num_rows > 0){
- if($password != $mypassword) {
- echo "Incorrect password";
- } else {
- session_register("myusername");
- session_register("mypassword");
- echo "Login Accepted";
- }
- }
- else {
- echo "Username not found";
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement