PDA

View Full Version : Showing the name of the logged user!


woxala123
06-09-2012, 03:14 PM
Hello and please help. I have written in dreamweaver login script.
How to make a page to display after logging a nickname and logged in user session.

login.php

<?php require_once('Connections/brama.php'); ?>
<?php require_once('Connections/brama.php');
session_start();?>
<?php
if (!function_exists("GetSQLValueString")) {
function GetSQLValueString($theValue, $theType, $theDefinedValue = "", $theNotDefinedValue = "")
{
if (PHP_VERSION < 6) {
$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['login'])) {
$loginUsername=$_POST['login'];
$password=$_POST['haslo'];
$MM_fldUserAuthorization = "";
$MM_redirectLoginSuccess = "index1.php";
$MM_redirectLoginFailed = "register.php";
$MM_redirecttoReferrer = false;
mysql_select_db($database_brama, $brama);

$LoginRS__query=sprintf("SELECT user_login, user_password FROM users WHERE user_login=%s AND user_password=%s",
GetSQLValueString($loginUsername, "text"), GetSQLValueString($password, "text"));

$LoginRS = mysql_query($LoginRS__query, $brama) or die(mysql_error());
$loginFoundUser = mysql_num_rows($LoginRS);
if ($loginFoundUser) {
$loginStrGroup = "";

if (PHP_VERSION >= 5.1) {session_regenerate_id(true);} else {session_regenerate_id();}
//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 );
}
}
?>
<link href="css/vBulletin_3_Default/controlpanel.css" rel="stylesheet" type="text/css" />
<form id="form1" name="form1" method="POST" action="<?php echo $loginFormAction; ?>">
<div align="center">
<table width="180" cellpadding="0" cellspacing="0">
<tr>
<td height="30"><br /> </td>
</tr>
<tr>
<td width="50">Login:</td>
<td><input type="text" name="login" maxlength="32" /> </td>
</tr>
<tr>
<td width="50">Hasło:</td>
<td><input type="password" name="haslo" maxlength="32" /> </td>
</tr>
<tr>
<td align="center" colspan="2"><input type="submit" value="Zaloguj się." /> <br /> </td>
</tr>
</table>
</div>
<p align="center">&nbsp;</p>
</form>