Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- $db_host = "localhost"; //this is where we write inn the host of the server we are trying to conect to
- $db_username = "root"; //we write in the username and the password we were given by olaf.
- $db_pass = "usn";
- $db_name = "dayz_1";// here we write in the name of the database we are trying to conect to
- // get values pass from form in index.php file
- $username = $POST['user'];
- $password = $POST['pass'];
- //to prevent injection from mysql
- $username = stripcslashes($username);
- $password = stripcslashes($password);
- $username = mysqli_real_escape_string($username);
- $password = mysqli_real_escape_string($password);
- //Connect to the server and select database.
- $link = mysqli_connect("localhost", "root", "usn", "dayz_1");
- //Query the database for user
- $result = $mysqli_query("select * from login where username = '$username' and password = '$password'")
- or die("Failed to query database ".mysqli_connect_error());
- $row = mysqli_fetch_array($result);
- if ($row['username'] == $username && $row['$password'] == $password){
- echo"login success! welcome " .$row['username'];
- } else {
- echo "failed to login!";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement