Как да скрия логин формата след "логване"

katsar0v

Registered
Код:
<?php
session_start();
include 'config.php';
$user=trim($_POST['user']);
$pass=trim($_POST['pass']);
if($_SESSION['log']===true)
{
echo '
<center>Влязохте в контролния панел :)</center>
';

}
else
{
if(strlen($user)>2 && strlen($pass)>2){
if($user && $pass)
{
$_SESSION['log']=true; 
header('Location: index.php'); 
}
}
}
?>
<html>
<body bgcolor="cccccc">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" /> 
<title>Katsarov</title>
</head><center>
<div style="background:#f2f2f2; width:250px; border:1px #999 solid">
<form action="index.php" method="post">
Потребител:<input type="text" name="user"><br>
Парола:<input type="text" name="pass"><br>
<input type="submit" value="Влез">
</form>
<input type="button" value="Регистрация"></div></center>
</body>
</html>
След като се логне потребител , отгоре се изписва текст , но това отдолу (логин формата) не се изтрива :(
 
Код:
<?php
session_start();
include 'config.php';
$user=trim($_POST['user']);
$pass=trim($_POST['pass']);
if($_SESSION['log']===true)
{
?>
<html>
<body bgcolor="cccccc">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Katsarov</title>
</head><center>
<div style="background:#f2f2f2; width:250px; border:1px #999 solid">
<form action="index.php" method="post">
Потребител:<input type="text" name="user"><br>
Парола:<input type="text" name="pass"><br>
<input type="submit" value="Влез">
</form>
<input type="button" value="Регистрация"></div></center>
</body>
</html>
<?php	
echo '
<center>Влязохте в контролния панел :)</center>
';

}
else
{
if(strlen($user)>2 && strlen($pass)>2){
if($user && $pass)
{
$_SESSION['log']=true;
header('Location: index.php');
}
}
}
?>
Просто сложи формата в иф-а който проверява дали сесията е стартирана
 
Код:
<?php
session_start();
include 'config.php';
$user=trim($_POST['user']);
$pass=trim($_POST['pass']);
if($_SESSION['log']===true)
{
echo '
<center>Влязохте в контролния панел :)</center>
';
exit();
}
else
{
if(strlen($user)>2 && strlen($pass)>2){
if($user && $pass)
{
$_SESSION['log']=true;
header('Location: index.php');
}
}
}
?>
<html>
<body bgcolor="cccccc">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Katsarov</title>
</head><center>
<div style="background:#f2f2f2; width:250px; border:1px #999 solid">
<form action="index.php" method="post">
Потребител:<input type="text" name="user"><br>
Парола:<input type="text" name="pass"><br>
<input type="submit" value="Влез">
</form>
<input type="button" value="Регистрация"></div></center>
</body>
</html>

Просто пишеш exit(); там там когато си се логнал в края и то спира да чете останалата част след него.

//php_masters така може да избъгяса, все пак пича не иска да му се променя начина му на писане..
 
Това със exit() , го пробвах ама .... премахна абсолютно всичко
На мен ми трябва да се махне полето което даже съм оформил с див :)
След логин разбира се :)
exit() не ми върши работа, защото ако има и други работи в сайта и те ще се премахнат :(
 
<?php
session_start();
include 'config.php';
$user=trim($_POST['user']);
$pass=trim($_POST['pass']);
if($_SESSION['log']===true)
{
echo '
<center>Влязохте в контролния панел :)</center>
';

}
else
{
?>
<html>
<body bgcolor="cccccc">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=windows-1251" />
<title>Katsarov</title>
</head><center>
<div style="background:#f2f2f2; width:250px; border:1px #999 solid">
<form action="index.php" method="post">
Потребител:<input type="text" name="user"><br>
Парола:<input type="text" name="pass"><br>
<input type="submit" value="Влез">
</form>
<input type="button" value="Регистрация"></div></center>
</body>
</html>
<?php
if(strlen($user)>2 && strlen($pass)>2){
if($user && $pass)
{
$_SESSION['log']=true;
header('Location: index.php');
}
}
}
?>
по-горе бях объркал малко кода, така ще работи
 

Back
Горе