-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathremove.php
More file actions
48 lines (42 loc) · 1.28 KB
/
Copy pathremove.php
File metadata and controls
48 lines (42 loc) · 1.28 KB
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
<html>
<head>
<link rel="stylesheet" type="text/css" href="style.css">
</head>
<h1>Remove Questions or Options</h1>
<h2>Enter a Question ID to remove a question</h2>
<h2>Enter a Question ID and Option to remove a specific option</h2>
<?php
$option = $_POST['option'];
$id=$_POST['id'];
if ($id) {
# This function reads your DATABASE_URL config var and returns a connection
# string suitable for pg_connect. Put this in your app.
function pg_connection_string_from_database_url() {
extract(parse_url($_ENV["DATABASE_URL"]));
return "user=$user password=$pass host=$host dbname=" . substr($path, 1); # <- you may want to add sslmode=require there too
}
# Here we establish the connection. Yes, that's all.
$db = pg_connect(pg_connection_string_from_database_url());
if ($option) {
$sql="DELETE FROM num".$id." WHERE OPTION='".$option."'";
$result=pg_query($db,$sql);
} else {
$sql="DROP TABLE num".$id;
$result=pg_query($db,$sql);
}
pg_close($db);
}
if(isset($_POST)) {
?>
<form method="POST" action="remove.php">
ID <input type="text" name="id"></input><br/>
Option <input type="text" name="option"></input><br/>
<input type="submit" name="submit" value="Remove Option"></input>
</form>
<?php
}
if ($id) {
echo "<h2>Removed</h2>";
}
?>
</html>