-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsurv1.php
More file actions
33 lines (27 loc) · 748 Bytes
/
surv1.php
File metadata and controls
33 lines (27 loc) · 748 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
27
28
29
30
31
32
33
<html>
<script src="../RIRA/survey.js"></script>
<?php
// Database connection details
$servername = "localhost";
$username = "root";
$password = "";
$dbname = "RIRA";
// Connect to the database
$conn = new mysqli($servername, $username, $password, $dbname);
// Check connection
if (!$conn) {
die("Connection failed: " . mysqli_connect_error());
}
// Get answer from POST request
$answer = $_POST['answer'];
// Create SQL query to insert data
$sql = "INSERT INTO responses (answer) VALUES ('$answer')";
if (mysqli_query($conn, $sql)) {
echo "Answer submitted successfully!";
} else {
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
}
// Close connection
mysqli_close($conn);
?>
</html>