Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- if (isset($_POST['remember'])) {
- session_set_cookie_params('604800');
- session_regenerate_id(true);
- }
- $mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_NAME);
- if ($mysqli->connect_errno) {
- echo "<p>MySQL error no {$mysqli->connect_errno} : {$mysqli->connect_error}</p>";
- exit();
- }
- $sql = "SELECT * from kandokowapers WHERE username='{$username}' AND password='{$password}' LIMIT 1";
- $result = $mysqli->query($sql);
- if ($result->num_rows != 1) {
- echo "<h3><strong>Error:</strong> Invalid Username/Password Combination Chikala Try Again</h3>";
- } else {
- // Authenticated, set session variables
- $user = $result->fetch_array();
- $_SESSION['user_id'] = $user['id'];
- $_SESSION['username'] = $user['username'];
- header("Location: profile.php");
- //do stuffs
- }
Add Comment
Please, Sign In to add comment