static function process_register() { if (user::checkLogin()) { header("Location: /console"); die; } $smarty = SSmarty::returnSmarty(); if (isset($_POST["register"]) && isset($_POST["user"]) && isset($_POST["pass"]) && isset($_POST["email"])) { try { if (self::createUser() && self::login()) { header("Location: /console"); die; } else { $smarty->assign("error", "Tworzenie uzytkownika nie powiodło się"); } } catch (Exception $ex) { $smarty->assign("error", "Błąd bazy danych"); } } $smarty->display("register.tpl"); }
$objuser = new user(); ?> <h3 class="heading">Message Board</h3> <div><b>Project: </b><a href='projects.php?id=<?php echo $_GET['pid']; ?> '><?php echo $projects['project_title']; ?> </a></div> <br /> <table cellpadding="0" cellspacing="0"> <tr><td><br /><input type="button" value="Post Message" onclick=" <?php if (!$objuser->checkLogin()) { echo "messageBox('Please Login to Post / Reply Message');"; } else { echo "loadPage('/ajax/project/form_postmessage.php?pid=" . $_GET['pid'] . "');"; } ?> " /></td></tr> <tr><td><small>Total Message Posted : <?php echo $objproject->countmessage($_GET['pid']); ?> </small></td></tr> </table> <hr /> <?php $messages = $objproject->getMessages($_GET['pid']);
<?php session_start(); $str = ''; if (isset($_SESSION['user-khachhang'])) { header('location: index.php'); } if (isset($_POST['user']) && isset($_POST['password'])) { require_once 'models/config.php'; require_once 'models/class.php'; require_once 'models/class-user.php'; $user_obj = new user(); $user = addslashes($_POST['user']); $pass = addslashes($_POST['password']); if ($user_obj->checkLogin($user, md5($pass))) { $user_info = $user_obj->getUserByUsername($user); $_SESSION['user-khachhang'] = $user; $_SESSION['fullname'] = $user_info['fullname']; $_SESSION['u_id'] = $user_info['u_id']; $_SESSION['IsAuthorized'] = true; if (isset($_POST['remember'])) { $_SESSION['timeout'] = time() + 1440 * 60; // thông tin login được lưu giữ trong 1 ngày $_SESSION['remember'] = 1; } header('location: index.php'); die; } else { $str = '</br><b style="color:red">Thông tin đăng nhập của bạn không đúng. Xin vui lòng thử lại</b>'; } }
<?php require "../content/db.php"; require "../content/user.class.php"; $user = new user($db); $username = $_POST["username"]; $password = $_POST["password"]; if ($user->checkLogin($user->getUserId($username), $password)) { $token = $user->setgetRandomToken($user->getUserId($username)); session_start(); $_SESSION["uid"] = $user->getUserId($username); $_SESSION["token"] = $token; $_SESSION["checked"] = true; if ($_POST["cookies"]) { setcookie("uid", $user->getUserId($username), time() + 31536000); setcookie("token", $token, time() + 31536000); } echo "true"; } else { echo "false"; }
<?php session_start(); session_regenerate_id(true); include 'content/user.class.php'; include 'content/db.php'; $user = new user($db); if (isset($_POST['username']) and isset($_POST['password'])) { if ($user->userExists($user->getUserId($_POST['username']))) { if ($user->checkLogin($user->getUserId($_POST['username']), $_POST['password'])) { $error = "Login erfolgreich. Wenn Sandy hier war, solltte hier eine Weiterleitung sein."; } else { $error = "MÖP MÖP MÖP... EY DA ISCH WASCH FALSCH!"; } } elseif (isset($_POST['firstn']) and isset($_POST['lastn']) and isset($_POST['loc']) and isset($_POST['pcode']) and isset($_POST['street']) and isset($_POST['house']) and isset($_POST['c_id']) and isset($_POST['email']) and isset($_POST['birth']) and isset($_POST['pw1']) and isset($_POST['pw2'])) { if ($_POST['pw1'] == $_POST['pw2']) { $user->newUser($_POST['firstn'], $_POST['lastn'], $_POST['username'], $_POST['loc'], $_POST['pcode'], $_POST['street'], $_POST['house'], $_POST['c_id'], $_POST['email'], $_POST['birth'], 0, $_POST['pw1']); } else { $error = "Ey du, gugst du! Die Passwörter sind nischt gleich, alter!"; } } } ?> <!DOCTYPE html> <html lang="de"> <head> <meta charset="utf-8"> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width, initial-scale=1">
<?php require_once 'config.php'; require_once 'class.php'; require_once 'class-user.php'; $user_obj = new user(); $user_check = mysqli_real_escape_string($user_obj->dbc, $_GET['user']); $pass_check = mysqli_real_escape_string($user_obj->dbc, $_GET['pass']); if ($user_obj->checkLogin($user_check, md5($pass_check))) { echo "dang nhap thanh cong"; } else { echo "dang nhap that bai"; } if (preg_match('/^[A-Za-z]{1}[A-Za-z0-9_]{5,31}$/', "datbka", $test)) { echo 'succeeded'; print_r($test); } else { echo 'failed'; print_r($test); } echo time();
<?php include 'header.php'; include 'user.php'; ?> <form method="POST" action=""> <a href="register_form.php"> Регистрация </a> <p> Потребителско име: <input type="text" name="username"> </p> <p> Парола: <input type="password" name="password"> </p> <input type="submit" value="submit" name='submit'> </form> <?php if (isset($_POST['submit'])) { $login = new user(); echo $login->checkLogin($_POST); if (isset($login->errors['login_empty'])) { echo 'Попълнете полетата.'; } if (isset($login->errors['login_wrong'])) { echo 'Невалидни данни.'; } } include 'footer.php';
<div id="main"> <div class="lc"> <div class="login"> <div> <?php $objuser = new user(); if ($objuser->checkLogin()) { ?> <ul style="display: block;"> <li>Logged in as <span class="black_small"><b><?php echo $objuser->getLoggedType(); ?> </b></span></li> <li>Welcome <span class="black_small"><b><?php echo $objuser->getLoggedUserName() . ","; ?> </b></span></li> <li><span class="black_small"><a href="account.php">Manage Account</a></span></li> <li><span class="black_small"><a href="javascript:;" onclick="loadPage('changepassword.php');">Change Password</a></span></li> <li><span class="black_small"><a href="logout.php">Logout</a></span></li> </ul> <?php } else { ?> <form name="frmLogin" action="/ajax/user/submit_login.php" method="post" onSubmit="if(validateForm(this)) submitFormOnFloat(this); return false;"> <div class="formRow"> <span class="inlineBlock" style="width:60px; vertical-align:middle">Email</span> <input type="text" name="username" id="username" class="input_box vldnoblank" style="vertical-align:middle" /><span class="checkStatus"></span> <input type="hidden" name="redirect" value="http://<?php echo $_SERVER['HTTP_HOST'] . $_SERVER['PHP_SELF'] . "?" . $_SERVER['QUERY_STRING']; ?>
<?php //error_reporting(E_ALL & ~E_NOTICE); error_reporting(E_ALL); require_once "view.class.php"; require_once "user.class.php"; require_once "session.class.php"; $view = new view(); $user = new user(); $session = new session(); // ログインしていなければログインフォームに戻ります // if (!$user->checkLogin()) { $view->setValue("posted_email", $session->get("posted_email")); var_dump($_SESSION); echo $session->get("error_message"); echo $view->render("login_form.php"); $session->clearAll(); } else { echo $view->render("mypage.php"); }