php session_start if isset _SESSION login isset _SESSION passwd Header

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
<?php
session_start();
if (!isset($_SESSION['login']) ||
!isset($_SESSION['passwd']))
Header("Location: 3.php");
if($_SESSION['passwd']==$_SESSION['checkPass'])
{
echo "Вы успешно вошли!<br>";
echo "Ваш ник:".$_SESSION['checkName']."<br>";
echo "Ваш пароль:".$_SESSION['checkPass']."<br>";
echo "Ваше слово:".$_SESSION['checkWord']."<br>";
if (!isset($_GET['Ок'])){
echo "<form>
Новый пароль: <input type=password name=passwd>
<input type=submit name=ОК value=Ок>
</form>";
}
else
{
$_SESSION['passwd']=$_GET['passwd'];
$oldUser = $_SESSION['checkName'].":".$_SESSION['checkPass'].":".$_SESSION['checkWord'];
$newUser = $_SESSION['checkName'].":".$_SESSION['passwd'].":".$_SESSION['checkWord'];
$fileText=file_get_contents($_SESSION['checkFile']);
$fileText=str_replace($oldUser, $newUser,$fileText);
file_put_contents($_SESSION['checkFile'], $fileText);
$_SESSION['checkPass'] = $_SESSION['passwd'];
Header("Location: 3.2.php");
}
}
else
{
if (!isset($_GET['Ок'])){
echo "<form>
Секретное слово ?: <input type=text name=secretWord>
<input type=submit name=Ок value=Ок>
</form>";
}
else
{
$word=$_GET['secretWord'];
if($word==$_SESSION['checkWord'])
{
echo "Ваш пароль:".$_SESSION['checkPass'];
echo "<a href=\"3.php\">Попробовать снова</a>";
}
else
{
echo "Секретное слово введено не верно";
echo "<a href=\"3.php\">Попробовать снова</a>";
}
}
}
?>