Commit 7bad3412 authored by trh010's avatar trh010

lots of changes

parent d655cfa4
<!DOCTYPE html>
<html><head></head>
<body>
<?php
session_start();
$user = $_SESSION["user"];
$password = $_SESSION["pwd"];
$database = $_SESSION["database"];
echo $user . "<br>" . $password . "<br>" . $database . "<br>";
$conn = mysql_connect("db.eg.bucknell.edu",$user,$password);
if (!$conn)
die("Cound not connect to database");
if (!$conn) die("Cound not connect to database");
mysql_select_db($database) or die("Unable to select database");
......@@ -29,5 +31,5 @@
mysql_free_result($result);
mysql_close($conn);
?>
?></body>
</html>
\ No newline at end of file
body {
padding-top: 20px;
padding-bottom: 20px;
}
.navbar {
margin-bottom: 20px;
}
\ No newline at end of file
<?php
session_start();
header("Location: ". $url . $_POST["actions"]);
header("Location: ". $_SESSION["url"] . $_POST["actions"]);
?>
<?php
session_start();
$user = $_SESSION["user"];
$password = $_SESSION["pwd"];
$database = $_SESSION["database"];
$table = $_POST["table"];
$conn = mysql_connect("db.eg.bucknell.edu",$user,$password);
if (!$conn) die("Cound not connect to database");
mysql_select_db($database) or die("Unable to select database");
$result = mysql_query("SELECT * FROM {$table}");
if (!$result)
die("Query to show tuples from table failed!" . mysql_error());
$fields_num = mysql_num_fields($result);
echo "<h1>Table: {$table}</h1>";
echo "<table border='1'><tr>";
// Print headers
for($i = 0; $i < $fields_num; $i++) {
$field = mysql_fetch_field($result);
echo "<th>{$field->name}</th>";
}
echo "</tr>\n";
// Print data
while($row = mysql_fetch_row($result)) {
echo "<tr>";
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
mysql_free_result($result);
mysql_close($conn);
?>
<!DOCTYPE html>
<html><head></head>
<body>
<?php
session_destroy();
session_start();
$user = $_POST["user"];
$password = $_POST["pwd"];
......@@ -6,6 +10,7 @@
$_SESSION["user"] = $user;
$_SESSION["pwd"] = $password;
$_SESSION["database"] = $database;
echo $_SESSION["user"] . "<br>" . $_SESSION["pwd"] . "<br>" . $_SESSION["database"] . "<br>";
/*
echo $_SESSION["user"];
echo $_SESSION["pwd"];
......@@ -37,4 +42,5 @@
echo "<input type=\"submit\" value=\"Submit\">";
echo "</form>";
?>
?></body>
</html>
\ No newline at end of file
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="">
<meta name="author" content="">
<link rel="shortcut icon" href="./icon/icon.jpg">
<!-- Bootstrap core CSS -->
<link href="./css/bootstrap.css" rel="stylesheet">
<!-- Bootstrap theme -->
<link href="./css/bootstrap-theme.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="./css/navbar.css" rel="stylesheet">
<title>Grocery Store</title>
</head>
<body>
<!-- Static navbar -->
<div class="navbar navbar-default" role="navigation">
<div class="navbar-header">
<a class="navbar-brand" href="#">CS305 - Grocery Store</a>
</div>
<div class="navbar-collapse collapse">
<ul class="nav navbar-nav navbar-right">
<li><a href="http://www.eg.bucknell.edu/~trh010/cs305/test.html">Login Page</a></li>
</ul>
</div><!--/.nav-collapse -->
</div>
<!-- <div class="jumbotron">
<h1>Navbar example</h1>
<p>This example is a quick exercise to illustrate how the default, static navbar and fixed to top navbar work. It includes the responsive CSS and HTML, so it also adapts to your viewport and device.</p>
<p>
<a class="btn btn-lg btn-primary" href="../../components/#navbar" role="button">View navbar docs &raquo;</a>
</p>
</div> -->
<div class="container">
<?php
session_start();
$conn = mysql_connect("db.eg.bucknell.edu",$_SESSION["user"],$_SESSION["pwd"]);
if (!$conn) die("Cound not connect to database");
mysql_select_db($_SESSION["database"]) or die("Unable to select database");
switch ($_POST["job"]) {
case "admin":
case "manager":
echo "<h2>Employees</h2>";
$result = mysql_query("SELECT * FROM Employees");
if (!$result)
die("Query to show tuples from table failed!" . mysql_error());
$fields_num = mysql_num_fields($result);
echo "<table class=\"table table-hover\" ><thead><tr>";
// Print headers
for($i = 0; $i < $fields_num; $i++) {
$field = mysql_fetch_field($result);
echo "<th>{$field->name}</th>";
}
echo "</tr></thead>\n<tbody>\n";
// Print data
while($row = mysql_fetch_row($result)) {
echo "<tr>";
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
echo "</tbody>\n</table>";
mysql_free_result($result);
case "cashier":
echo "<h2>Checkout Log</h2>";
$result = mysql_query("SELECT * FROM CheckedOut");
if (!$result)
die("Query to show tuples from table failed!" . mysql_error());
$fields_num = mysql_num_fields($result);
echo "<table class=\"table table-hover\" ><thead><tr>";
// Print headers
for($i = 0; $i < $fields_num; $i++) {
$field = mysql_fetch_field($result);
echo "<th>{$field->name}</th>";
}
echo "</tr></thead>\n<tbody>\n";
// Print data
while($row = mysql_fetch_row($result)) {
echo "<tr>";
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
echo "</tbody>\n</table>";
mysql_free_result($result);
case "stocker":
echo "<h2>Items Available</h2>";
$result = mysql_query("SELECT * FROM GroceryShelves");
if (!$result)
die("Query to show tuples from table failed!" . mysql_error());
$fields_num = mysql_num_fields($result);
echo "<table class=\"table table-hover\" ><thead><tr>";
// Print headers
for($i = 0; $i < $fields_num; $i++) {
$field = mysql_fetch_field($result);
echo "<th>{$field->name}</th>";
}
echo "</tr></thead>\n<tbody>\n";
// Print data
while($row = mysql_fetch_row($result)) {
echo "<tr>";
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
echo "</tbody>\n</table>";
mysql_free_result($result);
default: # Customer
echo "<h2>Items</h2>";
$result = mysql_query("SELECT * FROM ItemList");
if (!$result)
die("Query to show tuples from table failed!" . mysql_error());
$fields_num = mysql_num_fields($result);
echo "<table class=\"table table-hover\" ><thead><tr>";
// Print headers
for($i = 0; $i < $fields_num; $i++) {
$field = mysql_fetch_field($result);
echo "<th>{$field->name}</th>";
}
echo "</tr></thead>\n<tbody>\n";
// Print data
while($row = mysql_fetch_row($result)) {
echo "<tr>";
foreach($row as $cell)
echo "<td>$cell</td>";
echo "</tr>\n";
}
echo "</tbody>\n</table>";
mysql_free_result($result);
break;
}
mysql_close($conn);
?>
</div> <!-- /container -->
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="https://code.jquery.com/jquery-1.10.2.min.js"></script>
<script src="./js/bootstrap.min.js"></script>
</body>
</html>
......@@ -23,11 +23,11 @@
<body>
<div class="container">
<form class="form-signin" action="main.php" method="post" role="form">
<form class="form-signin" action="secondary.php" method="post" role="form">
<h2 class="form-signin-heading">Please sign in to database</h2>
<input type="text" name="user" class="form-control" placeholder="Username" required autofocus>
<input type="password" name="pwd" class="form-control" placeholder="Password" required>
<h4> User Role: <select name="job" size="1" Font size="2">
<h4> User Role: <select name="job" size="1" Font size="2">
<option value="admin" selected>Admin</option>
<option value="customer">Customer</option>
<option value="manager">Manager</option>
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment