-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert.php
More file actions
44 lines (39 loc) · 1.2 KB
/
insert.php
File metadata and controls
44 lines (39 loc) · 1.2 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
<DOCTYPE html>
<html lang = "en">
<head>
<meta charset = "utf-8">
<title>PHP/MySQL tests</title>
</head>
<body>
<div id = "wrapper">
<?php
error_reporting(E_ALL);
ini_set("display_errors", 1);
$target = "upload/";
$filehash = md5_file($_FILES['image']['tmp_name']);
$target = $target . $filehash . basename($_FILES['image']['name']);
$image = $filehash . ($_FILES['image']['name']);
$tags = $_POST['tags'];
$username = "ankhar";
$password = "fireforge5";
$host = "mydb5.cs.unc.edu";
$database = "comp523p1db";
mysql_connect($host, $username, $password) or
die("Can not connect to database: ".mysql_error());
mysql_select_db($database) or die("Can not select the database: ". mysql_error());
mysql_query("INSERT INTO tbl_images (image_url) VALUES ('$image')") or die(
"Cannot insert".mysql_error());
mysql_query("INSERT INTO tbl_tags (tag_name) VALUES ('$tags')") or die(
"Cannot insert".mysql_error());
if(move_uploaded_file($_FILES['image']['tmp_name'], $target))
{
echo "The file ". $target."has been uploaded,
and your information has been added to the directory";
}
else{
echo "Sorry, there was a problem uploading your file.";
}
?>
</div>
</body>
</html>