-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEditEventphp.php
More file actions
79 lines (55 loc) · 2.1 KB
/
Copy pathEditEventphp.php
File metadata and controls
79 lines (55 loc) · 2.1 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
<html>
<body>
<?php
$eventname=$_POST["EventName"];
$description=$_POST["Description"];
$hallnum=$_POST["SelectHall"];
$date=$_POST["Date"];
$old=$_POST["Old"];
//$poster=$_POST["EventPoster"];
$con = mysql_connect("localhost","root","");
if (!$con)
{
die('Could not connect: '.mysql_error());
}
mysql_select_db("Opera", $con);
//replace space with _
$eventname2 = preg_replace('/\s+/', '_', $eventname);
$str = "SELECT hno from hall WHERE hname= '".$hallnum."'";
//echo $str;
$result =mysql_query( $str, $con); //get hall number
$hno = mysql_fetch_array($result);
//if file is upload
if ( is_uploaded_file($_FILES["EventPoster"]["tmp_name"]) )
{
// echo "Error: " . $_FILES["EventPoster"]["error"] . "<br />";
//store uploaded file
move_uploaded_file($_FILES['EventPoster']["tmp_name"],'EventImages\\'.$eventname2.'.jpg');
$str = "UPDATE Event SET edate='".substr($date,0,10)."', etime= '".substr($date,11,8)."', name= '".$eventname."', edescription= '".$description."', poster= '".$eventname2."', featured= 'NULL', hnumber = ".$hno[0]." where name ='".$old."'";
//( edate,etime, name, edescription, poster, featured, hnumber) SELECT '". substr($date,0,10)."', '". substr($date,11,8)."', \"".$eventname."\", \"".$description."\",\"".$eventname ."\", 1, hno from hall WHERE hname=\"".$hallnum."\"";
}
else {
$str = "UPDATE Event SET edate='".substr($date,0,10)."', etime= '".substr($date,11,8)."', name= '".$eventname."', edescription= '".$description."',featured= 'NULL', hnumber = ".$hno[0]." where name ='".$old."'";
}
//echo $str;
$result =mysql_query( $str, $con);
//redirect user!
if (!$result)
{
echo '<script type="text/javascript">
window.onload = function () { alert("ERROR!: EVENT COULD NOT BE UPDATED"); }
</script>';
echo "<script>setTimeout(\"location.href = 'CreateEvent.php';\",0);</script>";
}
if ($result)
{
echo '<script type="text/javascript">
window.onload = function () { alert("Event UPDATED Successfully!"); }
</script>';
echo "<script>setTimeout(\"location.href = 'Calendar.php';\",2);</script>";
exit();
}
mysql_close($con);
?>
</body>
</html>