-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.php
123 lines (114 loc) · 3.5 KB
/
update.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
117
118
119
120
121
122
123
<?php
include("header.php");
include("connection.php");
if(isset($_POST[publish]))
{
move_uploaded_file($_FILES["file"]["tmp_name"],
"upload/" . $_FILES["file"]["name"]);
$img = $_FILES["file"]["name"];
$originalDate = $_POST[lastdate];
$newDate = date("Y-m-d", strtotime($originalDate));
$var = $_POST[lastdate];
$dateo = date("Y-m-d", $_POST[lastdate]);
///$dateofbirth = date("Y-m-d", strtotime($db_date));
//$dateo = date("Y-m-d", strtotime($_POST[date]));
$sql="INSERT INTO updates(title,descr,date,time,type,image_path)
VALUES
('$_POST[title]','$_POST[description]','$newDate','$_POST[time]','$_POST[type]','$img')";
if (!mysqli_query($con,$sql,$con))
{
die('Error: ' . mysqli_error($con));
}
$publish = $_POST[type] . " Published successfully...";
}
?>
<SCRIPT LANGUAGE="JavaScript">
function generate()
{
if(document.form1.title.value=="")
{
alert("enter the title");
return false;
}
if(document.form1.description.value=="")
{
alert("enter the description");
return false;
}
if(document.form1.lastdate.value=="")
{
alert("enter the date");
return false;
}
}
</script>
<div id="main">
<div id="content" class="left">
<div class="highlight">
<h3>Post News</h3>
<strong><a href="viewnews.php">View News</a></strong>
<form action="" method="post" enctype="multipart/form-data" name="form1" id="form1">
<p> <?php echo $publish ; ?></p>
<table width="450" border="0">
<tr>
<td width="93">Title</td>
<td width="350"><input name="title" type="text" id="title" size="50" /></td>
</tr>
<tr>
<td><label for="institutetype3">Description</label></td>
<td><textarea name="description" id="description" cols="45" rows="5"></textarea></td>
</tr>
<tr>
<td>Image</td>
<td><label for="file"></label>
<input type="file" name="file" id="file" /></td>
</tr>
<tr>
<td>Date</td>
<td>
<script language="javascript" type="text/javascript" src="datetimepicker.js">
</script>
<input type="Text" id="lastdate" name="lastdate" maxlength="25" size="25"><a href="javascript:NewCal('lastdate','ddmmyyyy',false,24)"><img src="cal.gif" width="16" height="16" border="0" alt="Pick a date"></a></td>
</tr>
<tr>
<td>Time</td>
<td><input name="time" type="text" id="time" value="<?php echo date("h:i:s"); ?>" size="25" /></td>
</tr>
<tr>
<td>Type
<label for="type2"></label></td>
<td><select name="type" id="type">
<option value="news">News & Updates</option>
<option value="events">Events</option>
</select></td>
</tr>
<tr>
<td> </td>
<td> </td>
</tr>
<tr>
<td colspan="2"><input type="submit" name="publish" id="publish" value="publish" onclick="return generate()"/></td>
</tr>
</table>
</form>
<p> </p>
</div>
<div class="projects">
<div class="item"></div>
<div class="item">
<div class="cl"> </div>
</div>
</div>
</div>
<?php
include("sidebar.php");
?>
<div class="cl"> </div>
</div>
<div class="shadow-l"></div>
<div class="shadow-r"></div>
<div class="shadow-b"></div>
</div>
<?php
include("footer.php");
?>