Example #1
0
<?php

session_start();
if (isset($_SESSION['validacao']) === true) {
    header("Location: main.php");
} else {
    include "config.php";
    include "conexao.php";
    include "classes/db.class.php";
    $OO = new DB();
    /* *********************************************************************************** */
    // Inicia Funcao de Login
    if (isset($_POST['email']) && isset($_POST['senha'])) {
        $email = $_POST['email'];
        $senha = md5($_POST['senha']);
        $OO->Login($conexao, $dir_userphoto, $email, $senha);
    }
    // Inicia Funcao de Cadastro
    if (isset($_POST['email_cadastra']) && isset($_POST['senha_cadastra'])) {
        $email = $_POST['email_cadastra'];
        $senha = md5($_POST['senha_cadastra']);
        $usuario = $_POST['usuario_cadastra'];
        $cidade = $_POST['cidade_cadastra'];
        $sexo = $_POST['sexo_sign'];
        $OO->Registro($conexao, $dir_userphoto, $email, $senha, $usuario, $cidade, $sexo);
        if (!isset($_SESSION['alerts'])) {
            $OO->Login($conexao, $dir_userphoto, $email, $senha);
        }
    }
    /* *********************************************************************************** */
    ?>
Example #2
0
        if (!ereg("^[0-9a-zA-Z\\_]*\$", $_GET['u'])) {
            rtnmsg(3, "用户名只允许字母,数字,下划线");
        }
        $user = $DB->Query("tl_user", "uname", $_GET['u']);
        if (strlen($_GET['u']) < 4) {
            rtnmsg(3, "用户名太短");
        }
        if (!$user['id']) {
            rtnmsg(5, "用户不存在");
        }
        $pw = md5(md5(md5($_GET['p'])));
        if ($user['upass'] != $pw) {
            rtnmsg(5, "密码错误");
        }
        $_SESSION['uid'] = $user['id'];
        $DB->Login($user['id']);
        rtnmsg(0, "登陆成功");
    } else {
        rtnmsg(1, "信息不完整");
    }
    //登陆 END
} elseif ($_GET['m'] == "reg") {
    //注册 START
    if ($_GET['u'] || $_GET['p'] || $_GET['v'] || $_GET['e']) {
        if (!ereg("^[0-9a-zA-Z\\_]*\$", $_GET['u'])) {
            rtnmsg(3, "用户名只允许字母,数字,下划线");
        }
        $user = $DB->Query("tl_user", "uname", $_GET['u']);
        if (!filter_var($_GET['e'], FILTER_VALIDATE_EMAIL)) {
            rtnmsg(1, "邮箱错误");
        }