-
Notifications
You must be signed in to change notification settings - Fork 0
/
updateUser.php
36 lines (23 loc) · 1 KB
/
updateUser.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
<?php
include 'db.php';
$id = $_GET['updateid'];
$sql = "SELECT * FROM users WHERE id = ".$id;
$result =$pdo->query($sql);
$row = $result->fetch();
$username = $row['username'];
$email = $row['email'];
$bio = $row['bio'];
$gender = $row['gender'];
$password = $row['password'];
if(isset($_POST['submit'] )){
$username = $_POST['username'];
$email = $_POST['email'];
$bio = $_POST['bio'];
$gender = $_POST['gender'];
$password = $_POST['password'];
$stmt = $pdo->prepare('UPDATE users SET id=$id, username= $username, email=$email, bio=$bio, gender=$gender, password=$password WHERE id=$id');
$result=$stmt ->execute( array( 'id' => $id, 'username' => $username, 'email' => $email, 'bio' => $bio, 'gender' => $gender, 'password' => $password ) );
if($result){
echo '<p>User at id=' ." ". $_POST['id'] ." ". 'successfully updated!</p><br>';
}else{ echo '< p>User at id is invalid or missing!</p><br>';}
}