-
Notifications
You must be signed in to change notification settings - Fork 0
/
modify.php
92 lines (77 loc) · 2.94 KB
/
modify.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
<?php
session_start();
require_once('database.php');
if (isset($_POST['modify'])) {
//$id = $_POST['idM'] ?? '';
$username = $_POST['usernameM'] ?? '';
$password = $_POST['passwordM'] ?? '';
$email= $_POST['emailM'] ?? '';
$indirizzo = $_POST['indirizzoM'] ?? '';
/*$query = "
SELECT id
FROM users
WHERE username = :username
";
$check = $pdo->prepare($query);
$check->bindParam(':username', $_SESSION['session_user'], PDO::PARAM_STR);
$check->execute();
$user = $check->fetchAll(PDO::FETCH_ASSOC);
echo 'ciao ',count($user),' ';*/
$query = "
UPDATE users
SET username= :username, email= :email, indirizzo= :indirizzo
WHERE id= :id
";
$check = $pdo->prepare($query);
//$check->bindParam(':id', $id, PDO::PARAM_STR);
$check->bindParam(':id', $_SESSION['session_identificatore'], PDO::PARAM_STR);
$check->bindParam(':username', $username, PDO::PARAM_STR);
//$check->bindParam(':password', $password_hash, PDO::PARAM_STR);
$check->bindParam(':email', $email, PDO::PARAM_STR);
$check->bindParam(':indirizzo', $indirizzo, PDO::PARAM_STR);
$check->execute();
if ($check->rowCount() > 0) {
$msg = 'Registrazione eseguita con successo';
$_SESSION['session_user'] = $username;
//$_SESSION['session_password'] = $user['password'];
$_SESSION['session_email'] = $email;
$_SESSION['session_indirizzo'] = $indirizzo;
$_SESSION['session_identificatore'] = $id;
header("location: ../index.php");
} else {
//echo $_SESSION['session_identificatore'];
$msg = 'Problemi con l\'inserimento dei dati %s ';
}
printf($msg, '<a href="../index.php">torna indietro</a>');
exit;
}else{
//$usernn=$_GET["usern"];
$query = "
SELECT id
FROM users
WHERE username = :username
";
$check = $pdo->prepare($query);
//$check->bindParam(':username', $username, PDO::PARAM_STR);
$check->bindParam(':username', $_GET["usernn"], PDO::PARAM_STR);
$check->execute();
$user = $check->fetchAll(PDO::FETCH_ASSOC);
//echo $_GET['usern'];
//exit;
if ($_SESSION['session_user']==$_GET["usernn"]){
echo "Nusato";
//exit;
}
elseif (count($user) > 0) {
$msg = 'Username già in uso %s';
echo "usato";
} else {
echo "Nusato";
//$query = "
// INSERT INTO users
//VALUES (0, :username, :password)
//";
}
exit;
}
?>