Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php if (!empty($_POST)):?>
- <?php
- $servername = "localhost:3307";
- $username = "root";
- $password = "usbw";
- try {
- $pu = $_POST["username"];
- $pp = $_POST["password"];
- $conn = new PDO("mysql:host=$servername;dbname=mydb", $username, $password);
- $stmt = $conn->prepare("SELECT Password FROM Users WHERE username = :username");
- $stmt->bindParam(":username", $pu);
- $ran = $stmt->execute();
- if($ran){
- $val = $stmt->fetch();
- if($val["Password"] == $pp){
- $_SESSION["loggedin"] = 1;
- $_SESSION["username"] = $pu;
- header("Location: /index.php");
- die();
- }
- }
- }catch(PDOException $e){
- echo "Connection failed: " . $e->getMessage();
- }
- ?>
- <?php endif; ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement