08-07-2013, 08:16 AM
Now ive fixed the session problem. now it dont say me Welcome back "user".
where "user" must contains $_SESSION[uid] = $r[user_id];
here the new login2.php
<?php
session_start();
if(isset($_SESSION["uid"]))
{
?>
<script type="text/javascript">
setTimeout("location.href=index.php",5000);
</script>
<?php
}
include includes/settings/Config.php;
include includes/config.php;
include includes/functions.php;
If (isset($_POST[username]))
{
if (empty($_POST[username]) OR empty($_POST[password]))
{
echo "Error! One or more fields are empty. Youll be redirected in 5 seconds... Or click ";
?>
<a href="register.php">here.</a>
<script type="text/javascript">
setTimeout("location.href=login.php",5000);
</script>
<?php
die;
}
$conn = new mysqli($ip,$sqluser,$sqlpw,$userdb);
if (mysqli_connect_errno() == 0)
{
$user = $conn->real_escape_string(htmlspecialchars(clean_str(strtolower($_POST[username]))));
$pass = $conn->real_escape_string(htmlspecialchars(strtolower($_POST[password])));
$qusr = "SELECT * FROM ".$Server[auth].".bg_user WHERE user_id = $user AND truepasswd = $pass";
$resusr = $conn->query($qusr);
If ($resusr->num_rows > 0)
{
echo <img src="images/msg/succ.png" width="50" height="50" alt="Error"><br>;
echo Logged Successfully ! You will be redirected in 2 seconds !;
echo ;
$_SESSION[utente]="ok";
$r = mysql_fetch_array( $result );
$_SESSION[uid] = (int)$r[user_code];
$_SESSION[pwd] = $r[truepasswd];
$_SESSION[name] = $r[user_id];
$User = $r[user_id];
$TRPWD = $r[truepasswd];
} else {
echo <img src="images/msg/error.png" width="50" height="50" alt="Error"><br>;
echo Username or password wrong ! Login Failed<br>;
echo <meta http-equiv="refresh" content="10; url=index.php">;
echo $qusr;
}
}
} else {
echo Username or Password is not setted.;
}
?>
and here the session check where $User contains username, but if i put in welcome back "user" the page will deface.
<?php
if (isset($User)) {
echo > Welcome back .$_SESSION[name]..;
} else {
echo <a href="login.php"> > Login Page</a>;
}
?>
Someone can help me ?


