Modificare parola
Scris: Vin Iul 01, 2011
vreau ca daca te loghezi cu succes sa poti schimba parola iar data viitoare cand te vei loga sa te poti loga deja cu parola noua iar cea veche sa nu mai fie valida.
test.php
admin.php
test.php
admin.php
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 />