Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ////index.php/////
- /////////////////
- <?php
- require_once('config.php');
- require_once('inc/style.css');
- include('inc/functions.php');
- if(is_logged_in()) /** Use function is_logged_in */
- {
- echo 'hello';
- } else { /** If is_logged_in is not set: ELSE */
- require('inc/login.php');
- }
- ?>
- ////functions.php/////
- /////////////////////
- function is_logged_in() /** Checks if user is logged in */
- {
- $islogged = false; /** Set variable FALSE */
- if (isset($_SESSION['username'], $_SESSION['password'])) { /** If username/password isset */
- $islogged = true; /** If username/password isset: variable TRUE" */
- }
- return $islogged; /** Return TRUE or FALSE */
- }
- ////login.php/////
- /////////////////
- <?php
- if($_GET['do'] == register){
- include('inc/register.php');
- }else{
- ?>
- <div id="login">
- <form name="login" method="post" action="">
- Username:
- <br/>
- <input type="text" name="username" id="username" class="textfield">
- <br/>
- Password:
- <br/>
- <input type="password" name="password" id="password" class="textfield1">
- <br/>
- <input type="submit" name="login" value="Login" class="submit">
- </form>
- <a href='?do=register'>Register now!</a><br/>
- <?php
- if (isset($_POST['login'])) {
- $username = $_POST['username'];
- $password = (md5($_POST['password']));
- $query = "SELECT * FROM users WHERE username = '$username' AND password = '$password'";
- $result = mysql_query($query);
- if (mysql_num_rows($result) > 0) {
- $_SESSION['username'] = $_POST['username'];
- $_SESSION['password'] = $_POST['password'];
- redirect('index.php', '0');
- } else {
- echo 'Wrong information.';
- }
- }
- }
- ?>
- </div>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement