This repository has been archived by the owner on Jan 20, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathprofile_send.php
62 lines (57 loc) · 1.85 KB
/
profile_send.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
<?php
require_once 'sys/functions/general.php';
require_once 'sys/functions/fetchers.php';
checkUserIsOnline();
$username = $_POST['username'];
$mail = $_POST['e-mail'];
$password = $_POST['password'];
$password_again = $_POST['password-again'];
$id = $_SESSION['user_id'];
if($username != null && $username == $_SESSION['user_name']){
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DB);
$mysqli -> set_charset("UTF8");
}
if($password != null && $password_again != null){
if($password == $password_again){
}else{
header("Location: profile.php?er=pw");
}
}
if($username != null && $mail != null && $password != null && $password_again != null){
if($password != $password_again){
header("Location: profile.php?er=pw");
}
if(!filter_var($mail, FILTER_VALIDATE_EMAIL)){
header("Location: profile.php?er=email");
}
if($username == $_SESSION['user_name']){
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DB);
$mysqli -> set_charset("UTF8");
$query = "SELECT * FROM Users WHERE name='$username'";
$result = $mysqli -> query($query);
if(mysqli_num_rows($result) > 2){
header("Location: profile.php?er=ex");
}else{
$query = "UPDATE Users SET name='$username', pass='$password', mail='$mail' WHERE id='$id'";
$stmt = $mysqli -> prepare($query);
$stmt -> execute();
session_destroy();
header("Location: profile.php?er=suc");
}
}else{
$mysqli = new mysqli(DB_HOST, DB_USER, DB_PASS, DB_DB);
$mysqli -> set_charset("UTF8");
$query = "SELECT * FROM Users WHERE name='$username";
$result = $mysqli -> query($query);
if(mysqli_num_rows($result) > 1){
header("Location: profile.php?er=ex");
}else{
$query = "UPDATE Users SET name='$username', pass='$password', mail='$mail' WHERE id='$id'";
$stmt = $mysqli -> prepare($query);
$stmt -> execute();
session_destroy();
header("Location: profile.php?er=suc");
}
}
}
?>