Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php require_once('Connections/conn.php'); ?>
- <?php
- if (!function_exists("GetSQLValueString")) {
- function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
- {
- $theValue = get_magic_quotes_gpc() ? stripslashes($theValue) : $theValue;
- $theValue = function_exists("mysql_real_escape_string") ? mysql_real_escape_string($theValue) : mysql_escape_string($theValue);
- switch ($theType) {
- case "text":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "long":
- case "int":
- $theValue = ($theValue != "") ? intval($theValue) : "NULL";
- break;
- case "double":
- $theValue = ($theValue != "") ? "'" . doubleval($theValue) . "'" : "NULL";
- break;
- case "date":
- $theValue = ($theValue != "") ? "'" . $theValue . "'" : "NULL";
- break;
- case "defined":
- $theValue = ($theValue != "") ? $theDefinedValue : $theNotDefinedValue;
- break;
- }
- return $theValue;
- }
- }
- ?>
- <?php
- // *** Validate request to login to this site.
- if (!isset($_SESSION)) {
- session_start();
- }
- $loginFormAction = $_SERVER['PHP_SELF'];
- if (isset($_GET['accesscheck'])) {
- $_SESSION['PrevUrl'] = $_GET['accesscheck'];
- }
- if (isset($_POST['username'])) {
- $loginUsername=$_POST['username'];
- $password=$_POST['pass'];
- $MM_fldUserAuthorization = "username";
- $MM_redirectLoginSuccess = "home.php";
- $MM_redirectLoginFailed = "login.php";
- $MM_redirecttoReferrer = false;
- mysql_select_db($database_conn, $conn);
- $LoginRS__query=sprintf("SELECT username, pass, username FROM member WHERE username=%s AND pass=%s",
- GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));
- $LoginRS = mysql_query($LoginRS__query, $conn) or die(mysql_error());
- $loginFoundUser = mysql_num_rows($LoginRS);
- if ($loginFoundUser) {
- $loginStrGroup = mysql_result($LoginRS,0,'username');
- //declare two session variables and assign them
- $_SESSION['MM_Username'] = $loginUsername;
- $_SESSION['MM_UserGroup'] = $loginStrGroup;
- if (isset($_SESSION['PrevUrl']) && false) {
- $MM_redirectLoginSuccess = $_SESSION['PrevUrl'];
- }
- header("Location: " . $MM_redirectLoginSuccess );
- }
- else {
- header("Location: ". $MM_redirectLoginFailed );
- }
- }
- ?>
- <html>
- <head>
- <title>session</title>
- </head>
- <body>
- <form method="POST" action="<?php echo $loginFormAction; ?>">
- Please enter you name:
- <input type="text" id="username" name="username" />
- <input type="password" id="pass" name="pass" />
- <input type="submit" value="Login" />
- </form>
- </body>
- </html>
- <?php
- session_start();
- ?>
- <html>
- <head>
- <title>welcome</title>
- </head>
- <body>
- <h1>Thnx for signing in</h1>
- <?php
- echo "Welcome" . " " . $_POST['username'];
- $_SESSION['chorva'] = $_POST['username'];
- ?>
- </body>
- </html>
- <?php
- session_start();
- ?>
- <html>
- <head>
- <title>welcome</title>
- </head>
- <body>
- <h1>Thnx for signing in</h1>
- <?php
- echo "Welcome" . " " . $_SESSION['MM_Username'];
- $_SESSION['chorva'] = $_SESSION['MM_Username'];
- ?>
- </body>
- </html>
- <?php
- if(isset($_SESSION['MM_Username'])){
- echo "Welcome ".$_SESSION['MM_Username'];
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement