Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- $db_username = "peoplein"; //Input your database username here
- $db_password = "xxxxxxx"; //Input your database password here
- $db_host = "localhost"; //Input your database host here
- $db_name = "xxxxxxxx"; //Input your database name here
- $options = array(PDO::MYSQL_ATTR_INIT_COMMAND => 'SET NAMES utf8');
- try {
- $connection = new PDO("mysql:host={$db_host};dbname={$db_name};charset=utf8", $db_username, $db_password, $options);
- $connection->setAttribute(PDO::ATTR_ERRMODE, PDO::ERRMODE_EXCEPTION);
- }
- catch(PDOException $ex) {
- echo "Cannot connect to database.";
- }
- header('Content-Type: text/html; charset=utf-8');
- ?>
- <!doctype html>
- <html>
- <head>
- <title>Login</title>
- </head>
- <body>
- <?php
- if (isset($_POST["user"])) {
- $user = $_POST["user"];
- }
- else {
- $user = "";
- }
- if (isset($_POST["pass"])) {
- $pass = $_POST["pass"];
- }
- else {
- $pass = "";
- }
- $query="SELECT * FROM login WHERE username=:username";
- $params=(array(':username' => $user));
- try{
- $stmt = $connection->prepare($query);
- $result = $stmt->execute($params);
- }
- catch(PDOException $ex){
- echo ("Failed to run query: " . $ex->getMessage());
- }
- $fetch = $stmt->fetch();
- $passwordfetch=$fetch['password'];
- if ($pass == $passwordfetch)) {
- session_start();
- $_SESSION['sess_user']=$user;
- ?>
- <meta http-equiv='refresh' content="0; url=http://peopleinvestment.ro/filip/admin.php">
- <?php
- }
- else {
- echo "Invalid Information";
- }
- ?>
- <center>
- <h3>Login</h3>
- <form action="" method="POST">
- Username: <input type="text" name="user">
- Password: <input type="password" name="pass">
- <input type="submit" value="Login" name="submit" />
- </form>
- </body>
- </html>
Advertisement
Add Comment
Please, Sign In to add comment