Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- ------------------------------------------------------
- login-validasi.php: menangkap variable yang dikirimkan
- pada file login.php
- ------------------------------------------------------
- */
- require_once '../config/config.php';
- if ( isset($_POST['username']) && isset($_POST['password']) ) {
- $sql_check = "SELECT id,
- telegram_id
- FROM users
- WHERE
- username=?
- AND
- password=?
- LIMIT 1";
- $check_log = $db->prepare($sql_check);
- $check_log->bind_param('ss', $username, $password);
- $username = $_POST['username'];
- $password = md5( $_POST['password'] ); //enkripsi md5 just for example
- $check_log->execute();
- $check_log->store_result();
- if ( $check_log->num_rows == 1 ) {
- $check_log->bind_result($id, $telegram_id, $auth_code);
- // This is user session:
- while ( $check_log->fetch() ) {
- $_SESSION['user_login'] = $username;
- $_SESSION['telegram_id'] = $telegram_id;
- }
- $check_log->close();
- // Jika berhasil login, maka akan diarahkan ke laman autentikasi
- header("location: autentikasi.php");
- exit();
- // Jika gagal tetap di laman login dan menampilkan error
- } else {
- header('location: login.php?err='.base64_encode('Invalid Username or Password!'));
- exit();
- }
- } else {
- header('location:login.php');
- exit();
- }
Add Comment
Please, Sign In to add comment