-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathedit-profile.php
169 lines (156 loc) · 8.47 KB
/
edit-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
<?php include "header.php";?>
<div class="collectible">
<div class="container">
<div class="row">
<div class="col-md-12">
<h2>Edit Profile</h2>
</div>
</div>
</div>
</div>
<section class="checkout section-padding-100">
<div class="container">
<div class="checkout__form">
<h4>User Profile</h4>
<form id="form_create_item" class="form-border" method="post" action="" enctype="multipart/form-data">
<div class="row" id="from_data">
<div class="col-lg-12 col-md-12">
<div class="row">
<div class="col-lg-12">
<div class="checkout__input">
<p>Upload your avatar<span>*</span></p>
<div class="upload-div">
<p>JPG, PNG, GIF, WEBP, MP4 or MP3. Up to 100 MB</p>
<input type="file" name="file" id="tokenimag" class="file" accept="image/*">
</div>
</div>
<!--<div class="checkout__input">-->
<!-- <p>Upload Cover avatar<span>*</span></p>-->
<!-- <div class="upload-div">-->
<!-- <p>JPG, PNG, GIF, WEBP, MP4 or MP3. Up to 100 MB</p>-->
<!-- <input type="file" name="file" id="tokenimag1" class="file" accept="image/*">-->
<!-- </div>-->
<!--</div>-->
</div>
<div class="col-lg-12">
<div class="checkout__input mt-20">
<p>User Name<span>*</span></p>
<input type="text" id="myusername" name="Name" placeholder="User Name">
</div>
</div>
<div class="col-lg-12">
<div class="checkout__input mt-20">
<p>Twitter Account<span></span></p>
<input type="text" id="tweetname" name="tweetname" placeholder="Tweeter Username">
</div>
</div>
<div class="col-lg-12">
<div class="checkout__input mt-20">
<p>Instagram Account<span></span></p>
<input type="text" id="instaname" name="instaname" placeholder="Instagram Username">
</div>
</div>
<div class="col-lg-12">
<div class="checkout__input mt-20">
<p>User Email</p>
<input type="email" id="email" name="email" placeholder="User Email">
</div>
</div>
<div class="col-lg-12">
<div class="checkout__input mt-30">
<p>Introduction</p>
<textarea rows="7" onkeyup="capitalizeFirstLetter()" id="description" name="description" placeholder="Introduction"></textarea>
</div>
</div>
</div>
<input type="text" name="Accounts" id="Accounts" value="" hidden="">
<button class="btn btn-primary w-100 rounded-50 font-weight-bold" name="submit" id="submit" value="save" onclick="updateInfo()" type="button">Update your personal information</button>
</div>
</div>
</form>
</div>
</div>
</section>
<script src="https://code.jquery.com/jquery-3.6.0.js" integrity="sha256-H+K7U5CnXl1h5ywQfKtSj8PCmoN9aaq30gDh27Xc0jk=" crossorigin="anonymous"></script>
<script>
$(document).ready( function(){
setTimeout(async function(){
// document.getElementById("loadingdiv").className = "d-block";
if(selectedAccount){
$("#Account").val(selectedAccount);
var formdata = new FormData();
formdata.append("address",selectedAccount);
var requestOptions = {
method: "POST",
body: formdata,
redirect: "follow",
};
fetch("./userdata.php", requestOptions)
.then((response) => response.json())
.then((nnewresult) => {
console.log(nnewresult);
$("#myusername").val(nnewresult[0].Username);
$("#email").val(nnewresult[0].Useremail);
$("#tweetname").val(nnewresult[0].Usertwitname);
$("#description").val(nnewresult[0].Userbio);
$("#instaname").val(nnewresult[0].Userinstaname);
})
}else{
Swal.fire({
icon: 'warning',
title: 'warning...',
text: 'Please connect your wallet',
})
}
},2000)
})
function capitalizeFirstLetter() {
// converting first letter to uppercase
let str=document.getElementById("description").value;
const capitalized = str.charAt(0).toUpperCase() + str.slice(1);
document.getElementById("description").value=capitalized;
}
async function updateInfo(){
if(selectedAccount){
document.getElementById("loadingdiv").className = "d-block";
let tokenimage=document.getElementById('tokenimag');
let tokenimage1=tokenimage;
var formdata = new FormData();
formdata.append("Username",document.getElementById("myusername").value);
formdata.append("tokenimage",tokenimage.files[0]);
formdata.append("tokenimage1",tokenimage1.files[0]);
formdata.append("Email",document.getElementById("email").value);
formdata.append("Bio",document.getElementById("description").value);
formdata.append("Instagram",document.getElementById("instaname").value);
formdata.append("Twitter",document.getElementById("tweetname").value);
formdata.append("address",selectedAccount);
var requestOptions = {
method: "POST",
body: formdata,
redirect: "follow",
};
fetch("./updateuserinfo.php", requestOptions)
.then((response) => response.text())
.then((result) => {
console.log(result)
document.getElementById("loadingdiv").className = "d-none";
Swal.fire({
icon: "success",
title: "Great...",
text: "Profile Update Successfully",
}).then((ok) => {
location.href = "./my_item.php"+"?v="+Math.floor((Math.random() * 1000000) + 1);
});
}).catch({
})
}else{
Swal.fire({
icon: 'warning',
title: 'warning...',
text: 'Please connect your wallet',
})
}
}
</script>
<!-- ======= Footer ======= -->
<?php include "footer.php"?>