Example #1
0
<?php

if (!isset($_SESSION)) {
    session_start();
}
if (isset($_POST['password'])) {
    require_once 'includes/functions.php';
    get_db_ready();
    try_to_login($_POST['username'], $_POST['password'], 'users');
    if (isset($_SESSION['userpass'])) {
        header('Location: index.php');
    } else {
        $message = "login error";
    }
}
?>
<!DOCTYPE HTML>
<html>
<head>
    <title>login</title>
</head>
    <link rel="stylesheet" type="text/css" href="style/main.css" >
<body>
    <div id="loginform">
        <label>Login Form</label>
        <?php 
if (isset($message)) {
    echo '<span style="color: red;">' . $message . '</span>';
}
?>
        <form id="login" action="login.php" method="post">
Example #2
0
    //handle the login result
    if (mysqli_num_rows($retval) == 0) {
        echo "<script language='javascript'> alert('wrong log name!');\r\n                window.history.go(-1);\r\n                </script>";
    } else {
        $complete_ary = mysqli_fetch_array($retval, MYSQLI_ASSOC);
        if ($complete_ary[Config_user::password] == $password) {
            $_SESSION['CURRENT_LOGIN_USER'] = $username;
            $_SESSION['CURRENT_LOGIN_ID'] = $complete_ary[Config_user::id];
            mysqli_free_result($retval);
            header("Location:Commodity_browse.php");
        } else {
            mysqli_free_result($retval);
            echo "<script language='javascript'> alert('wrong password!');\r\n                window.history.go(-1);\r\n                </script>";
        }
    }
}
if (isset($_POST['login'])) {
    try_to_login();
} else {
    if (isset($_POST['reg'])) {
        $smarty->display("Login&Register/register1.html");
    } else {
        if (isset($_POST['forget'])) {
            $smarty->display("forget.html");
        } else {
            //    echo "in";
            //    var_dump("$smarty");
            $smarty->display("Login&Register/Login.html");
        }
    }
}