Skip to content

Instantly share code, notes, and snippets.

@ElectApp
Created March 18, 2019 06:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ElectApp/f5a1a6b436a970f34953f33aca4a12bf to your computer and use it in GitHub Desktop.
Save ElectApp/f5a1a6b436a970f34953f33aca4a12bf to your computer and use it in GitHub Desktop.
<?php
//Thank SQL: https://www.w3schools.com/sql/sql_where.asp
$servername = "localhost"; //ใช้ localhost กรณี server อยู่บน online
$username = "พิมพ์ที่นี่"; //username ของ DirectAdmin/phpMyAdmin
$password = "พิมพ์ที่นี่"; //password ของ DirectAdmin/phpMyAdmin
$dbname = "test"; //ชื่อ database
// Create connection
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if ($conn->connect_error) {
die("Connection failed: " . $conn->connect_error);
}
//Get data from user
$name = $_POST['name'];
$pass = $_POST['password'];
//Filter on DB
$sql = "SELECT name, password FROM user_login_test WHERE (name='$name' && password='$pass')";
$result = $conn->query($sql);
if ($result->num_rows > 0) {
echo "Login successfully";
}else{
echo "name or password invalid!";
}
$conn->close();
?>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment