forked from DarshanMaradiya/OnlineMusic
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathaccount.php
135 lines (132 loc) · 3.27 KB
/
account.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
<?php
session_start();
if(isset($_SESSION['id']))
{
$logged_in=true;
include('dbcon.php');
$id=$_SESSION['id'];
$sql="SELECT * FROM `users` WHERE `id`='$id'";
$run=mysqli_query($con,$sql);
$data=mysqli_fetch_assoc($run);
}
else
{
header("Location: index.php");
}
?>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title><?php echo $data['name']; ?></title>
<link
rel="stylesheet"
href="https://cdn.materialdesignicons.com/4.9.95/css/materialdesignicons.min.css"
/>
<link
rel="stylesheet"
href="https://fonts.googleapis.com/css?family=Roboto&display=swap"
/>
<link rel="stylesheet" href="assets/css/styles.css" />
<link rel="stylesheet" href="assets/css/sidebar.css" />
<?php
if(isset($_POST['changename'])){
$usernameExist = false;
$newname = strtolower($_POST['username']);
$qry = "SELECT * FROM `users` WHERE `name` = '$newname'";
$run = mysqli_query($con, $qry);
$row = mysqli_num_rows($run);
if($row > 0)
{
$usernameExist = true;
?>
<script type="text/javascript">
alert('Username already Exists!! try different one!');
</script>
<?php
}
else
{
?>
<link rel="stylesheet" href="assets/css/snackbar.css" />
<div id="snackbar">Username changed <?php echo $newname; ?></div>
<?php
$qry = "UPDATE `users` SET `name`='$newname' WHERE `id`='$id'";
$run = mysqli_query($con, $qry);
header("Location: index.php");
}
}
?>
</head>
<body>
<?php
if($logged_in) {
include('sidebar.php');
account($data['verified']);
?>
<main class="main">
<?php
if($data['verified']==0)
{
?>
Your email address is not verified yet.<br>
<form action="account.php" method="post">
<input type="submit" name="verificationmail" value="Send mail">
</form>
<?php
if(isset($_POST['verificationmail'])){
require('functions.php');
// sending mail
$success = verifyMail($data['id'], $data['email'], $data['name']);
if($success){
?>
<script type="text/javascript">alert("Mail sent");</script>
<?php
}
else{
?>
<script type="text/javascript">alert("Try again");</script>
<?php
}
}
}
?>
<br>
Change username:
<form action="" method="post" name="uname">
<input type="text" name="username" id="username" placeholder="Enter new username">
<input type="submit" name="changename" value="Change">
</form>
To change password
<form action="account.php" method="POST">
<input type="submit" name="changepass" value="Change Password">
</form>
*You will get a link to reset password. The link is unique for you.
<?php
if(isset($_POST['changepass'])){
require('functions.php');
// sending mail
$success = changePass($data['id'], $data['email']);
if($success){
?>
<script type="text/javascript">alert("Change passwd link sent");</script>
<?php
header("Location: logout.php");
}
else{
?>
<script type="text/javascript">alert("fail");</script>
<?php
}
}
?>
</main>
<?php
}
else{
header("Location: login.php");
}
?>
</body>
</html>