Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
<html>
<head>
<title>First exercise on php</title>
<style type="text/css">
form {
position: relative;
top:200px;
vertical-align:text-top;
transform: translateY(-50%);
text-align:center
}
</style>
</head>
<body>
<form action="result.php" method="post">
Pick Category:
<select name="list">
<option value = "Drama">Drama</option>
<option value = "Comedy">Comedy</option>
<option value = "Horror">Horror</option>
</select>
Search:<input type="text" name="search_text"></input>
<input type="submit" value=" Submit Query"/>
</form>
</body>
</html>
65 changes: 65 additions & 0 deletions results.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
<style type="text/css">
#result{
font-family: Arial;font-size: 15px; font-weight:bold;
position: relative;
top:200px;
vertical-align:text-top;
transform: translateY(-50%);
text-align:center

}
</style>
<?php

$movies = array();
$drama = array();
array_push($drama, "The Shawshank Redemption");
array_push($drama, "The Green Mile");
array_push($drama, "Requiem for a Dream");
$comedy = array();
array_push($comedy, "The Hangover");
array_push($comedy, "Knocked Up");
array_push($comedy, "Due Date");
$horror = array();
array_push($horror, "Halloween");
array_push($horror, "The Conjuring");
array_push($horror, "The Shining");
array_push($movies,$drama);
array_push($movies,$comedy);
array_push($movies,$horror);

$movie_type=$_POST['list'];
$moviestxt=$_POST['search_text'];

if($moviestxt!="")
{

if ($movie_type =='Drama')
{
for($i=0;$i<3;$i++)
if(stristr($movies[0][$i],$moviestxt) == TRUE)
echo "<div id='result'>".$movies[0][$i]."</div><br>";
}

elseif ($movie_type == 'Comedy')
{
for($i=0;$i<3;$i++)
if(stristr($movies[1][$i], $moviestxt) == TRUE)
echo "<div id='result'>".$movies[1][$i]."</div><br>";
}

elseif ($movie_type == 'Horror')
{
for($i=0;$i<3;$i++)
if(stristr($movies[2][$i], $moviestxt) == TRUE)
echo "<div id='result'>".$movies[2][$i]."</div><br>";
}

else echo "Movie not found!";
}

else echo "<div id='result' style='color:red'>Please insert a string</div>";

echo "<div id='result'><a href='index.html'>Return to search form</a></div>";

?>