function validate()
{
    include "wines.php";
    $username = $_REQUEST['username'];
    $password = $_REQUEST['password'];
    $obj = new wines();
    $obj->connect();
    $obj->validation($username, $password);
    if ($row = $obj->fetch()) {
        echo '{"status":1, "message":"User found"}';
    } else {
        echo '{"status":0, "message":"User not found"}';
    }
}
			<input type="radio" name="cat" value="White">White<br>
			<input type="radio" name="cat" value="Red">Red<br>
		<input type="submit" value="BROWSE">
	</form>
	</body>
	<?php 
if (isset($_REQUEST['cat'])) {
    include_once "adb.php";
    include "wines.php";
    if ($_REQUEST['cat'] == "Sparkling") {
        $cat = $_REQUEST['cat'];
    } elseif ($_REQUEST['cat'] == "Fortified") {
        $cat = $_REQUEST['cat'];
    } elseif ($_REQUEST['cat'] == "Sweet") {
        $cat = $_REQUEST['cat'];
    } elseif ($_REQUEST['cat'] == "White") {
        $cat = $_REQUEST['cat'];
    } elseif ($_REQUEST['cat'] == "Red") {
        $cat = $_REQUEST['cat'];
    }
    $obj = new wines();
    $obj->browseBy($cat);
    echo "<table border='1'>";
    echo "<tr style='background-color:purple; color:white;text-align:center'>\n\t\t\t<td>Wine ID</td><td>Wine Name</td><td>Wine Type</td><td>Year</td>\n\t\t\t<td>Winery</td></tr>";
    while ($row = $obj->fetch()) {
        echo "<tr><td>{$row['wine_id']}</td><td>{$row['wine_name']}</td><td>{$row['wine_type']}</td><td>{$row['year']}</td><td>{$row['winery_name']}</td></tr>";
    }
    echo "</table>";
}
?>
</html>
				exit.hidden=false;
            }

            function exitView(){
				contentSpace.innerHTML="";
				exit.hidden=true;
			}
		</script>
		<div style="text-align:right">
			<a href="logout.php"> Log Out</a>
		</div>
		<div style="text-align:left">
			<button id="change" onclick="loadAddWine()">Add Wine</button>
		</div>
		<span style="color:red;cursor:pointer" id="exit" onclick="exitView()" hidden="true"><b>Exit</b></span>
		<div id="contentSpace"></div>
	</body>
<?php 
include_once "adb.php";
include "wines.php";
$obj = new wines();
$obj->view_wines();
echo "<br>";
echo "<table border='1'>";
echo "<tr style='background-color:purple; color:white;text-align:center'>\n\t\t\t<td>Wine ID</td><td>Wine Name</td><td>Wine Type</td><td>Year</td>\n\t\t\t<td>Winery</td><td></td></tr>";
while ($row = $obj->fetch()) {
    echo "<tr><td>{$row['wine_id']}</td><td onclick='loadViewWine({$row['wine_id']})' style='cursor:pointer'>{$row['wine_name']}</td><td>{$row['wine_type']}</td><td>{$row['year']}</td><td>{$row['winery_name']}</td><td onclick='loadEditWine({$row['wine_id']})' style='cursor:pointer'><u><b>Edit</b></u></td></tr>";
}
echo "</table>";
?>
</html>
							<?php 
include_once "wines.php";
$obj1 = new wines();
$obj1->get_wine_type();
while ($row = $obj1->fetch()) {
    echo "<option value='{$row['wine_type_id']}''>{$row['wine_type']}</option>";
}
?>
						</select>
				</div><br>
			<div>Year: <input type="text" name="yr" size="30" required></div><br>
			<div>Winery: <select name="winery_id">
							<option value="0">--Select Winery--</option>
							<?php 
include_once "wines.php";
$obj2 = new wines();
$obj2->get_winery();
while ($row = $obj2->fetch()) {
    echo "<option value='{$row['winery_id']}''>{$row['winery_name']}</option>";
}
?>
						</select>
				</div><br>
			<div>Description: <textarea name="wd" cols="30" rows="5"></textarea></div><br>
			
			<input type="submit" name="do" value="ADD">
		</form>
		<form action="upload.php" method="post" enctype="multipart/form-data">
			Select image to upload: 
			<input type="file" name="fileToUpload" id="fileToUpload">
			<input type="submit" value="Upload Image" name="submit">
<?php

include_once "wines.php";
$obj = new wines();
$wid = $_REQUEST['wid'];
$obj->view_wine($wid);
$row = $obj->fetch();
echo "Wine Name : " . $row['wine_name'] . "<br>";
echo "Winery : " . $row['winery_name'] . "<br>";
echo "Quantity on Hand : " . $row['on_hand'] . "<br>";
echo "Unit Price : " . $row['cost'];
echo "<br/>";
echo "Region : " . $row['region_name'] . "<br>";
?>
 
<html>
	<head>
		<title>Search</title>
	</head>

	<body>
		<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.10.2/jquery.min.js"></script>

		<form action="searchWines.php" method="GET">
		Enter Wine Name : <input ="text" size="30" name="str">
		<input type="submit" value="Search">
		</form>

	</body>

<?php 
if (isset($_REQUEST['str'])) {
    include_once "adb.php";
    include "wines.php";
    $search_text = $_REQUEST['str'];
    $obj = new wines();
    echo "<table border='1'>";
    echo "<tr style='background-color:purple; color:white;text-align:center'>\n\t\t\t<td>Wine ID</td><td>Wine Name</td><td>Wine Type</td><td>Year</td>\n\t\t\t<td>Winery Name</td></tr>";
    $obj->search_wines($search_text);
    while ($row = $obj->fetch()) {
        echo "<tr><td>{$row['wine_id']}</td><td>{$row['wine_name']}</td><td>{$row['wine_type']}</td><td>{$row['year']}</td><td>{$row['winery_name']}</td></tr>";
    }
    echo "</table>";
}
?>
</html>
	<head>
		<title>Sorting</title>
	</head>
	<body>
		<form action="sortWines.php">
			Sort by : 
			<input type="radio" name="field" value="wine_name"> Wine Name
			<input type="radio" name="field" value="price"> Price
			<input type="submit" value="SORT">
		</form>
	</body>
<?php 
if (isset($_REQUEST['field'])) {
    include_once "adb.php";
    include "wines.php";
    if ($_REQUEST['field'] == "wine_name") {
        $field = $_REQUEST['field'];
    } elseif ($_REQUEST['field'] == "price") {
        $field = $_REQUEST['field'];
    }
    $obj = new wines();
    $obj->sortBy($field);
    echo "<table border='1'>";
    echo "<tr style='background-color:purple; color:white;text-align:center'>\n\t\t\t<td>Wine ID</td><td>Wine Name</td><td>Price</td></tr>";
    while ($row = $obj->fetch()) {
        echo "<tr><td>{$row['wine_id']}</td><td>{$row['wine_name']}</td><td>{$row['price']}</td></tr>";
    }
    echo "</table>";
}
?>
</html>
<?php

if (isset($_REQUEST['uname'])) {
    session_start();
    include_once "wines.php";
    $uname = $_REQUEST['uname'];
    $p_word = $_REQUEST['pwd'];
    $obj = new wines();
    $row = $obj->validation($uname, $p_word);
    if (!$row) {
        echo "Ooops! Wrong credentials... :(";
    } else {
        $_SESSION['cust_id'] = $row['cust_id'];
        $_SESSION['uname'] = $row['user_name'];
        $_SESSION['pwd'] = $_REQUEST['password'];
        header("location:viewAfterLogIn.php");
    }
}
?>
<html>
	<head>
		<title>Sign-In</title>
		<script src="jquery-2.1.3.js"></script>
	<script>
	
		function sendRequest(requestURL){
			var obj = $.ajax({url:requestURL, async:false});
			var response =$.parseJSON(obj.responseText);
			return response;	
		}
		
include_once "wines.php";
$obj2 = new wines();
$obj2->get_year();
while ($row = $obj2->fetch()) {
    echo "<option value='{$row['year']}''>{$row['year']}</option>";
}
?>
						</select>
				</div><br>
		<input type="submit" value="Search">
		</form>

	</body>

<?php 
if (isset($_REQUEST['wt'])) {
    include_once "adb.php";
    include_once "wines.php";
    $wine_type = $_REQUEST['wt'];
    $year = $_REQUEST['yr'];
    $obj = new wines();
    echo "<table border='1'>";
    echo "<tr style='background-color:purple; color:white;text-align:center'>\n\t\t\t<td>Wine ID</td><td>Wine Name</td><td>Wine Type</td><td>Year</td>\n\t\t\t<td>Winery Name</td></tr>";
    $obj->multiple_search($wine_type, $year);
    while ($row = $obj->fetch()) {
        echo "<tr><td>{$row['wine_id']}</td><td>{$row['wine_name']}</td><td>{$row['wine_type']}</td><td>{$row['year']}</td><td>{$row['winery_name']}</td></tr>";
    }
    echo "</table>";
}
?>
</html>
        echo "<option value='{$obj1['wine_type_id']}' selected>{$obj1['wine_type']}</option>";
    } else {
        echo "<option value='{$obj1['wine_type_id']}'>{$obj1['wine_type']}</option>";
    }
}
?>
			</select></div><br>
			<div>Year: <input type="text" value="<?php 
echo $row['year'];
?>
" name="yr" id="yr"></div><br>
			<div>Winery: <select name="winery_id" id="winery_id">
						<option value="0">--Select Winery--</option>
						<?php 
include_once "wines.php";
$obj = new wines();
$obj->get_winery();
while ($obj1 = $obj->fetch()) {
    if ($obj1['winery_id'] == $row['winery_id']) {
        echo "<option value='{$obj1['winery_id']}' selected>{$obj1['winery_name']}</option>";
    } else {
        echo "<option value='{$obj1['winery_id']}'>{$obj1['winery_name']}</option>";
    }
}
?>
						</select></div><br>
			<div>Description: <textarea name="wd" id="wd" cols="30" rows="5" value="<?php 
echo $row['description'];
?>
"></textarea></div>
			<input type="submit" value="UPDATE">