-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathratingUp.php
77 lines (48 loc) · 1.7 KB
/
ratingUp.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
<?php
include('connect.php');
if (isset($_POST['submit'])) {
$file = $_FILES['file']['tmp_name'];
$filename = strtolower($_FILES["file"]["name"]);
$type = strrchr($filename, ".");
$handle = fopen($file, "r");
if ($type == ".csv") {
while (($fileop = fgetcsv($handle, 1000, ",")) !== false) {
$id = $fileop[0];
$isbn = $fileop[1];
$rating = $fileop[2];
$sql = "INSERT INTO `DSS_Rating` (`userID`, `isbn`, `rating`) VALUES ('$id', '$isbn', '$rating')";
echo $sql;
$result = mysqli_query($conn, $sql);
echo $result;
}
if (sql) {
echo "Upload completed";
}
} else {
echo "invalid file type";
}
}
?>
<html>
<head>
<head>
<meta charset="utf-8">
<meta name="description" content="">
<meta name="author" content="">
<title>Book Suggestions</title>
<!-- Bootstrap core CSS -->
<link href="assets/css/bootstrap.css" rel="stylesheet">
<link href='http://fonts.googleapis.com/css?family=Lato:300,400,700,300italic,400italic' rel='stylesheet'
type='text/css'>
<link href='http://fonts.googleapis.com/css?family=Raleway:400,300,700' rel='stylesheet' type='text/css'>
</head>
<body>
<form method="post" action="ratingUp.php" enctype="multipart/form-data">
<input type="file" name="file" accept=".csv">
<br/><br/>
<input type="submit" name="submit" value="Submit">
</form>
<script src="assets/js/jquery.min.js"></script>
<script src="assets/js/bootstrap.min.js"></script>
</body>
</html>