-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinsert_data.php
57 lines (45 loc) · 1.66 KB
/
insert_data.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
<!-- THIS IS THE SUBMISSION PAGE FOR INSERTING ENTRIES-->
<html>
<head>
<link rel="stylesheet" href="StyleSheet.css">
</head>
</html>
<?php
session_start(); /*required for session data*/
unset($_SESSION['sqlQuery']); //resets session variable
$host = "localhost";
$_SESSION['user'] = $user = $_SESSION["user"];
$_SESSION['pass'] = $pass = $_SESSION["pass"];
$db_name = "fbca_visitation";
//create connection
$conn = mysqli_connect($host, $user, $pass, $db_name);
//test if connection failed
if(!$conn)
{
die("connection failed: "
. mysqli_connect_error()
. " (" . mysqli_connect_errno()
. ")"
);
}
mysqli_select_db($user, $conn);
$sql="INSERT INTO Families (F_ID, House, Street_Addr, Last_name, First_Name, Age, Visitation_Information_and_Description, Next_Visitation, Last_Visitation, Phone_Number, Status_)
VALUES ('$_POST[F_ID]','$_POST[House]','$_POST[Street_Addr]','$_POST[Last_name]','$_POST[First_Name]','$_POST[Age]','$_POST[Visitation_Info]','$_POST[Next_Visitation]','$_POST[Last_Visitation]','$_POST[Phone_Number]','$_POST[Status_]')";
if (mysqli_query($conn, $sql)) {
echo "New record created successfully";
} else {
echo '<form><button type="button" value="Return to previous page" onClick="javascript:history.go(-1)">Return to previous page</button></form>';
echo "Error: " . $sql . "<br>" . mysqli_error($conn);
die();
}
?>
<html>
<br/>
<form>
<button type='button' value='New Entry' onClick="location.href='entryInput.php'">Insert Another Entry</button><br/><br/>
<button type='button' value='Return to Main' onClick="location.href='database.php'">Return to Main</button>
</form>
</html>
<?php
mysql_close($conn);
?>