-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathI2.php
123 lines (112 loc) · 4.29 KB
/
I2.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
$db_connection = mysql_connect("localhost", "cs143", "") or die('Could not connect'.mysql_error());
if (!db_connection) {
$errmsg=mysql_error($db_connection);
print "Connection failed <br>";
exit(1);
}
mysql_select_db("CS143", $db_connection);
function AddMovieInfo($title, $year, $mpaarating, $company) //as well as genre
{
$query = "UPDATE MaxMovieID SET id = (id + 1)";
$queryResult = mysql_query($query);
$query = "SELECT id FROM MaxMovieID";
$queryResult = mysql_query($query);
$idNumber = mysql_fetch_row($queryResult);
$query = "INSERT INTO Movie VALUES ('$idNumber[0]', '$title', '$year', '$mpaarating', '$company')"; //adds to Movie table
$queryResult = mysql_query($query);
if ($queryResult)
{
print ("New movie information successfully added\n");
}
else
{
print ("Oh no!");
}
//add to Genre table
$query = "INSERT INTO Genre VALUES ('$idNumber[0]', )"; //need to get array of genres clicked!!!!
$queryResult = mysql_query($query);
if ($queryResult)
{
print ("New genre information successfully added");
}
else
{
print ("Oh no!");
}
}
$title = $_GET['title'];
$company = $_GET['company'];
$year = $_GET['year'];
$mpaarating = $_GET['mpaarating'];
$genre = $_GET['genre'];
//call movie function here - double check that default are null if not specified
if ($title && $company && $year && $mpaarating) //I'm thinking we might want to update our parts in 1B to say that genre can't be null/empty?
{
//If the title, company, and year match, then update Table
//Otherwise, add new record using maxMovieIdTable.
}
echo <<<HTMLCODE
<html>
<title>Add Movie Info</title>
<link rel="stylesheet" type="text/css" href="Project1C.css">
<div id="sidebar">
<ul>Add New Content:<br>
<li><a href="I1.php">Add Actor/Director</a></li>
<li><a href="I2.php">Add Movie Information</a></li>
<li><a href="I3.php">Add Comments</a></li>
<li><a href="I4.php">Add Movie/Actor Relation</a></li>
<li><a href="I5.php">Add Movie/Director Relation</a></li>
</ul>
<ul>Browsing Content:<br>
<li><a href="B1.php">Show Actor Information</a></li>
<li><a href="B2.php">Show Movie Information</a></li>
</ul>
<ul>Search Interface:<br>
<li><a href="S1.php">Search Actor/Movie</a></li>
</ul>
</div>
<div id="main">
Add New Movie Info<br>
<form method="GET" ACTION="I2.php">
Title : <input type="text" name="title" maxlength="20"><br/>
Company: <input type="text" name="company" maxlength="50"><br/>
Year : <input type="text" name="year" maxlength="4"><br/> <!-- Todo: validation-->
MPAA Rating :
<select name="mpaarating">
<option value="G">G</option>
<option value="NC-17">NC-17</option>
<option value="PG">PG</option>
<option value="PG-13">PG-13</option>
<option value="R">R</option>
<option value="surrendere">Surrendere</option>
</select>
<br>
Genre :
<input type="checkbox" name="genre" value="Action">Action</input>
<input type="checkbox" name="genre" value="Adult">Adult</input>
<input type="checkbox" name="genre" value="Adventure">Adventure</input>
<input type="checkbox" name="genre" value="Animation">Animation</input>
<input type="checkbox" name="genre" value="Comedy">Comedy</input>
<input type="checkbox" name="genre" value="Crime">Crime</input>
<input type="checkbox" name="genre" value="Documentary">Documentary</input>
<input type="checkbox" name="genre" value="Drama">Drama</input>
<input type="checkbox" name="genre" value="Family">Family</input>
<input type="checkbox" name="genre" value="Fantasy">Fantasy</input>
<input type="checkbox" name="genre" value="Horror">Horror</input>
<input type="checkbox" name="genre" value="Musical">Musical</input>
<input type="checkbox" name="genre" value="Mystery">Mystery</input>
<input type="checkbox" name="genre" value="Romance">Romance</input>
<input type="checkbox" name="genre" value="Sci-Fi">Sci-Fi</input>
<input type="checkbox" name="genre" value="Short">Short</input>
<input type="checkbox" name="genre" value="Thriller">Thriller</input>
<input type="checkbox" name="genre" value="War">War</input>
<input type="checkbox" name="genre" value="Western">Western</input>
<br>
<input type="submit" value="Submit!"/>
</form>
</div>
</html>
HTMLCODE;
mysql_close($db_connection);
?>