test.php
Cod: Selectaţi tot
<?php
$user = 'admin';
$pass = 'admin';
if(isset($_POST['submit']))
{
if(empty($_POST['user']) || empty($_POST['pass']))
{
echo 'All fields are required!';
}
elseif($_POST['user'] == $user && $_POST['pass'] == $pass )
{
header("Location: admin.php");
}
else
{
echo 'Username or Password is incorrect';
}
}
else
{
echo 'Log In !';
}
?>
<form action="" method="post">
<input type="text" name="user" />
<input type="password" name="pass" />
<input type="submit" name="submit" />
</form>
Cod: Selectaţi tot
<?php
if(defined($_SESSION['logged']))
{
if(isset($_POST['change']))
{
if(empty($_POST['pass']))
{
echo 'All fields are required!';
}
$_SESSION['pass'] = $_POST['pass'];
}
}
?>
You have succsesfully logged in !<br />
Your password now is <b><?php echo $_SESSION['pass']; ?></b> <br />
Change password: <br />
<form action="" method="post">
<input type="password" name="pass" />
<input type="submit" name="change" />
</form> <br />
<a href=test.php>Back?</a> <br />
Cod: Selectaţi tot
<?php
$user = 'admin';
$pass = 'admin';
if(isset($_POST['submit']))
{
if(empty($_POST['user']) || empty($_POST['pass']))
{
echo 'All fields are required!';
}
elseif($_POST['user'] == $user && $_POST['pass'] == $pass )
{
header("Location: admin.php");
}
else
{
echo 'Username or Password is incorrect';
}
}
else
{
echo 'Log In !';
}
?>
<form action="" method="post">
<input type="text" name="user" />
<input type="password" name="pass" />
<input type="submit" name="submit" />
</form>
Cod: Selectaţi tot
<?php
if(defined($_SESSION['logged']))
{
if(isset($_POST['change']))
{
if(empty($_POST['pass']))
{
echo 'All fields are required!';
}
$_SESSION['pass'] = $_POST['pass'];
}
}
?>
You have succsesfully logged in !<br />
Your password now is <b><?php echo $_SESSION['pass']; ?></b> <br />
Change password: <br />
<form action="" method="post">
<input type="password" name="pass" />
<input type="submit" name="change" />
</form> <br />
<a href=test.php>Back?</a> <br />