-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinsert_site.php
More file actions
97 lines (61 loc) · 2.03 KB
/
insert_site.php
File metadata and controls
97 lines (61 loc) · 2.03 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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<!DOCTYPE html>
<html>
<head>
<title>Search Engine in PHP</title>
</head>
<body bgcolor="gray">
<form action="insert_site.php" method="post" enctype="multipart/form-data">
<table bgcolor="orange" width="500" border="2" cellspacing="2" align="center">
<tr>
<td colspan="5" align="center"><h2>Inserting new website:</h2></td>
</tr>
<tr>
<td align="right"><b>Site Title:</b></td>
<td><input type="text" name="site_title" /></td>
</tr>
<tr>
<td align="right"><b>Site Link:</b></td>
<td><input type="text" name="site_link" /></td>
</tr>
<tr>
<td align="right"><b>Site Keywords:</b></td>
<td><input type="text" name="site_keywords" /></td>
</tr>
<tr>
<td align="right"><b>Site Description:</b></td>
<td><textarea cols="18" rows="8" name="site_desc"></textarea></td>
</tr>
<tr>
<td align="right"><b>Site Image:</b></td>
<td><input type="file" name="site_image" /></td>
</tr>
<tr>
<td align="center" colspan="5"><input type="submit" name="submit" value="Add Site Now"/></td>
</tr>
</table>
</form>
</body>
</html>
<?php
mysql_connect("localhost","root","");
mysql_select_db("search");
if(isset($_POST['submit'])){
$site_title = $_POST['site_title'];
$site_link = $_POST['site_link'];
$site_keywords = $_POST['site_keywords'];
$site_desc = $_POST['site_desc'];
$site_image = $_FILES['site_image']['name'];
$site_image_tmp = $_FILES['site_image']['tmp_name'];
if($site_title=='' OR $site_link=='' OR $site_keywords=='' OR $site_desc==''){
echo "<script>alert('please fill all the fields!')</script>";
exit();
}
else {
$insert_query = "insert into sites (site_title,site_link,site_keywords,site_desc,site_image) values ('$site_title','$site_link','$site_keywords','$site_desc','$site_image')";
move_uploaded_file($site_image_tmp,"images/{$site_image}");
if(mysql_query($insert_query)){
echo "<script>alert('Data inserted into table')</script>";
}
}
}
?>