-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.php
116 lines (84 loc) · 3.64 KB
/
test.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
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<html>
<head>
<title>php</title>
<body>
<?php
/* ------------------PERSONAL DETAILS-------------- */
$Fname = $_POST['Fname'];
$Minit = $_POST['Minit'];
$Lname = $_POST['Lname'];
$Age = $_POST['Age'];
$Address = $_POST['Address'];
$Cultivation_location = $_POST['Cultivation_location'];
/* ------------------WAREHOUSE-------------- */
$Dimension = $_POST['Dimension'];
$Location = $_POST['Location'];
$Storage_technique = $_POST['Storage_technique'];
$Ownership = $_POST['Ownership'];
/* ------------------MACHINES-------------- */
$Type = $_POST['Type1'] . "," . $_POST['Type2'] . "," . $_POST['Type3'] ;
$MID = $_POST['MID1'] . "," . $_POST['MID2'] . "," . $_POST['MID3'] ;
$Purchase_year = $_POST['year1'] . "," . $_POST['year2'] . "," . $_POST['year3'] ;
$Warranty = $_POST['warranty1'] . "," . $_POST['warranty2'] . "," . $_POST['warranty3'] ;
$Insurance = $_POST['Insurance'];
$Status = $_POST['Status1'] . "," . $_POST['Status2'] . "," . $_POST['Status3'] ;
/* ------------------LAND-------------- */
$Owner_name = $_POST['Owner_name'];
$PID = $_POST['PID'];
$Area = $_POST['Area'];
$Land_location = $_POST['Land_location'];
$Lcondition =$_POST['Condition1'] . "," . $_POST['Condition2'];
$Ownership_type = $_POST['Ownership_type'];
$Previous_stats = $_POST['prev_stats1'] . "," . $_POST['prev_stats2'];
/* ------------------SECURITY-------------- */
$UID = $_POST['UID'];
#$register1pwd = $_POST['register1pwd'];
#$register1pwd-repeat = $_POST['register1pwd-repeat']; */
/* ------------------------------------QUERY PART------------------------------------------------------------------------------------------ */
if (!empty($Fname) || !empty($Minit) || !empty($Age) || !empty($Address) || !empty($Cultivation_location) || !empty($Dimension) || !empty($Location) || !empty($Storage_technique) || !empty($Ownership) || !empty($Type) || !empty($MID) || !empty($year) || !empty($warranty) || !empty($Insurance) || !empty($Status) || !empty($Owner_name) || !empty($PID) || !empty($Area) || !empty($Land_location) || !empty($Ownership_type) || !empty($Previous_stats) || !empty($Condition) )
{
$servername = "localhost";
$username = "root";
$dbname ="sugan_SF";
// Create connection
$conn = new mysqli($servername, $username,"",$dbname);
// Check connection
if ($conn->connect_error)
{
die("Connection failed: " . $conn->connect_error);
}
else
{
$INSERT1 = "INSERT INTO FARMER(Fname,Minit,Lname,Age,UID,Address,Cultivation_location)
VALUES('$Fname','$Minit','$Lname','$Age','$UID','$Address','$Cultivation_location' ) ";
$INSERT2 = "INSERT INTO WAREHOUSE(eUID,Dimension,Location,Storage_technique,Ownership)
VALUES('$UID','$Dimension','$Location','$Storage_technique','$Ownership')";
$INSERT3 = "INSERT INTO MACHINERY(eUID,Type,MID,Purchase_year,Warranty,Insurance,Status)
VALUES('$UID','$Type','$MID','$Purchase_year','$Warranty','$Insurance','$Status' ) ";
$INSERT4 = " INSERT INTO LAND(Owner_name,Area,Land_location,Lcondition,Ownership_type,PID,Previous_stats,eUID)
VALUES('$Owner_name','$Area','$Land_location','$Lcondition','$Ownership_type','$PID','$Previous_stats','$UID')";
mysqli_query($conn,$INSERT1);
mysqli_query($conn,$INSERT2);
mysqli_query($conn,$INSERT3);
if(!mysqli_query($conn,$INSERT4))
{
echo("Error description: " . mysqli_error($conn));
}
echo("<script type=\"text/javascript\">
window.alert('New record has been added successfully');
window.location.href='REGISTER.html';
</script>");
$conn->close();
}
}
else
{
echo("<script type=\"text/javascript\">
window.alert('All fields are required!');
window.location.href='REGISTER.html';
</script>");
die();
}
?>
</body>
</html>