-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathquery.php
More file actions
26 lines (26 loc) · 900 Bytes
/
query.php
File metadata and controls
26 lines (26 loc) · 900 Bytes
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
<?php
require_once("config.php");
$connstr = "host=$DB_HOST port=$DB_PORT dbname=$DB_NAME user=$DB_USER password=$DB_PASS";
$conn = pg_pconnect($connstr);
if (isset($_POST["name"])){
$new_name = $_POST['name'];
$query = pg_query($conn, "UPDATE users SET name='$new_name' WHERE id = 1");
}
$name_query = pg_query($conn, "SELECT name FROM users WHERE id = 1");
$name = pg_fetch_row($name_query)[0];
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Actualizar tu nombre de perfil</title>
</head>
<body>
<p>Ahora mismo tu nombre de perfil es <?= $name ?>, ¿deseas cambiarlo?</p>
<form action="query.php" method="post">
<input type="text" size="160" name="name" id="name" placeholder="nuevo nombre">
<input type="submit" value="Cambiar">
</form>
</body>
</html>