-
Notifications
You must be signed in to change notification settings - Fork 0
/
profile.php
180 lines (164 loc) · 6.02 KB
/
profile.php
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
<?php
session_start();
if ($_SESSION['auth'] == 'yes_auth')
{
define('myeshop', true);
include 'include/db_connect.php';
include 'functions/functions.php';
if ($_POST["save_submit"])
{
$_POST["info_surname"] = clear_string($_POST["info_surname"]);
$_POST["info_name"] = clear_string($_POST["info_name"]);
$_POST["info_address"] = clear_string($_POST["info_address"]);
$_POST["info_phone"] = clear_string($_POST["info_phone"]);
$_POST["info_email"] = clear_string($_POST["info_email"]);
$error = array();
$pass = md5($_POST["info_pass"]);
$pass = strrev($pass);
$pass = "8md7udyd".$pass."2ui6z";
if($_SESSION['auth_pass'] != $pass)
{
$error[]='Неверный текущий пароль!';
}else
{
if($_POST["info_new_pass"] != "")
{
if(strlen($_POST["info_new_pass"]) < 7 || strlen($_POST["info_new_pass"]) > 15)
{
$error[]='Укажите новый пароль от 7 до 15 символов!';
}else
{
$newpass = md5(clear_string($_POST["info_new_pass"]));
$newpass = strrev($newpass);
$newpass = "8md7udyd".$pass."2ui6z";
$newpassquery = "pass='".$newpass."',";
}
}
if(strlen($_POST["info_surname"]) < 3 || strlen($_POST["info_surname"]) > 15)
{
$error[]='Укажите Фамилию от 3 до 15 символов!';
}
if(strlen($_POST["info_name"]) < 3 || strlen($_POST["info_name"]) > 15)
{
$error[]='Укажите Имя от 3 до 15 символов!';
}
if(!preg_match("/^(?:[a-z0-9]+(?:[-_.]?[a-z0-9]+)?@[a-z0-9_.-]+(?:\.?[a-z0-9]+)?\.[a-z]{2,5})$/i",trim($_POST["info_email"])))
{
$error[]='Укажите корректный email!';
}
if(strlen($_POST["info_phone"]) == "")
{
$error[]='Укажите номер телефона!';
}
if(strlen($_POST["info_address"]) == "")
{
$error[]='Укажите адрес доставки!';
}
}
if(count($error))
{
$_SESSION['msg'] = "<p align='left' id='form-error'>".implode('<br />',$error)."</p>";
}else
{
$_SESSION['msg'] = "<p align='left' id='form-success'>Данные успешно сохранены!</p>";
$dataquery = $newpassquery."surname='".$_POST["info_surname"]."',name='".$_POST["info_name"]."',email='".$_POST["info_email"]."',phone='".$_POST["info_phone"]."',address='".$_POST["info_address"]."'";
$update = mysql_query("UPDATE reg_user SET $dataquery WHERE login = '{$_SESSION['auth_login']}'",$link);
if ($newpass){ $_SESSION['auth_pass'] = $newpass; }
$_SESSION['auth_surname'] = $_POST["info_surname"];
$_SESSION['auth_name'] = $_POST["info_name"];
$_SESSION['auth_address'] = $_POST["info_address"];
$_SESSION['auth_phone'] = $_POST["info_phone"];
$_SESSION['auth_email'] = $_POST["info_email"];
}
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<link rel="icon" type="image/png" href="favicon-96x96.png" sizes="96x96">
<link href="css/reset.css" rel="stylesheet">
<link href="css/style.css" rel="stylesheet">
<link href="trackbar/trackbar.css" rel="stylesheet">
<script src="/js/jquery-1.8.2.min.js"></script>
<script src="/js/jcarousellite_1.0.1.js"></script>
<script src="/js/eshop-script.js"></script>
<script src="/js/jquery.cookie.min.js"></script>
<script src="/trackbar/jquery.trackbar.js"></script>
<script src="/js/TextChange.js"></script>
<title>Интернет Магазин Женской Косметики</title>
</head>
<body>
<?php include_once 'include/google-analytics.php'; ?>
<div id="block-body">
<?php
include("include/block-header.php");
?>
<div id="block-right">
<?php
include 'include/block-category.php';
include 'include/block-parfume.php';
include 'include/block-parameter.php';
include 'include/block-news.php';
?>
</div>
<div id="block-content">
<h3 class="title-h3" >Изменение профиля</h3>
<?php
if($_SESSION['msg'])
{
echo $_SESSION['msg'];
unset($_SESSION['msg']);
}
?>
<form method="post">
<ul id="info-profile">
<li>
<label for="info_pass">Текущий пароль</label>
<span class="star">*</span>
<input type="text" name="info_pass" id="info_pass" value="">
</li>
<li>
<label for="info_new_pass">Новый пароль</label>
<span class="star">*</span>
<input type="text" name="info_new_pass" id="info_new_pass" value="">
</li>
<li>
<label for="info_surname">Фамилия</label>
<span class="star">*</span>
<input type="text" name="info_surname" id="info_surname" value="<?php echo $_SESSION['auth_surname']; ?>">
</li>
<li>
<label for="info_name">Имя</label>
<span class="star">*</span>
<input type="text" name="info_name" id="info_name" value="<?php echo $_SESSION['auth_name']; ?>">
</li>
<li>
<label for="info_email">E-mail</label>
<span class="star">*</span>
<input type="text" name="info_email" id="info_email" value="<?php echo $_SESSION['auth_email']; ?>">
</li>
<li>
<label for="info_phone">Телефон</label>
<span class="star">*</span>
<input type="text" name="info_phone" id="info_phone" value="<?php echo $_SESSION['auth_phone']; ?>">
</li>
<li>
<label for="info_address">Адрес доставки</label>
<span class="star">*</span>
<textarea name="info_address" > <?php echo $_SESSION['auth_address']; ?> </textarea>
</li>
</ul>
<p align="right"><input type="submit" id="form_submit" name="save_submit" value="Сохранить"></p>
</form>
</div>
<?php
include 'include/block-random.php';
include 'include/block-footer.php';
?>
</div>
</body>
</html>
<?php
}else { header("Location: index.php");}
?>