-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadd.php
More file actions
70 lines (62 loc) · 2.4 KB
/
add.php
File metadata and controls
70 lines (62 loc) · 2.4 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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
<?php
//connect to database
include('connect_db.php');
if(isset($_POST["upload"]))
{
// upload file to the folder
define ('SITE_ROOT', realpath(dirname(__FILE__)));
$file_name= SITE_ROOT ."/uploads/".$_FILES["file"]["name"];
move_uploaded_file($_FILES["file"]["tmp_name"], $file_name);
//update the database
$title = mysqli_real_escape_string($conn, $_POST["title"]);
$name = mysqli_real_escape_string($conn, $_FILES["file"]["name"]);
$course = mysqli_real_escape_string($conn, $_POST["course"]);
$sql = "INSERT INTO notes(title,actual_name,course) VALUES('$title','$name', '$course')";
if(mysqli_query($conn,$sql)){
//success
}else{
echo "ERROR: " .mysqli_error($conn);
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Add your notes!</title>
<link rel="stylesheet" type="text/css" href="./add.css" />
<script type="text/javascript" src="./index.js" ></script>
<script src="https://ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js"></script>
</head>
<body>
<a href="index.php"><div class="logo"><img src="./assets/notes.png" /></div></a>
<div class="navbar_mainpage">
</div>
<div class="addmaterial_heading">Add Material</div>
<div class="adding_notes_info">
<form action="add.php" method="POST" enctype='multipart/form-data'>
<select name="course" class="input_course_field">
<option>Course 1</option>
<option>Course 2</option>
<option>Course 3</option>
<option>Course 4</option>
</select>
<input type="text" class="input_title_field" name="title" placeholder="Title for your notes"/><br>
<label for="input_upload_field" class="input_upload_decoration" >
click for uploading material then click upload (name of material uploaded will be hidden for security reasons)
</label>
<input type="file" id="input_upload_field" name="file" onchange="myfunc()" placeholder=""/><br>
<?php
if(isset($_POST["upload"]))
{
if(empty($_POST["title"]))
{
?>
<p class="warning"> Don't leave the field empty!</p>
<?php }else{
?>
<?php
}}?>
<input type="submit" class="input_submit_field" name="upload" value="Upload"></input>
</form>
</div>
</body>