PageRenderTime 127ms CodeModel.GetById 98ms app.highlight 1ms RepoModel.GetById 25ms app.codeStats 0ms

/middCalendar/insert1.php

https://github.com/gkipkorir/public_html
PHP | 155 lines | 136 code | 15 blank | 4 comment | 5 complexity | f61b916429f3ef3672618eb1f4c9af7e MD5 | raw file
  1<?php session_start(); ?>
  2<!DOCTYPE HTML>
  3
  4
  5<html>
  6	<head>
  7		<style>
  8		
  9			
 10			.logo {
 11				position: fixed;
 12				margin-top: 1%;
 13				margin-left: 38%;
 14				z-index: 2;
 15				opacity: .6;
 16			}
 17			.header {				
 18
 19				position:fixed;				
 20				background-color:gray;
 21				opacity: .9;
 22				width:100%;
 23				padding-top: 20px;
 24				padding-bottom: 20px;
 25				padding-right: 10%;
 26				padding-left: 10%;
 27				border-width: 3px;
 28				border-color: black;
 29				margin-top: 10%;
 30				margin-right: 0%;
 31				margin-left: 0%;
 32				z-index: 1;
 33			}
 34			.headerText {
 35				float: left;
 36				color: white;
 37				width: 13%  
 38			}
 39			.center {
 40				color:black;
 41				text-align:center;
 42			}
 43			.main {
 44				position: fixed;
 45				background-color: white;
 46				opacity: .8;
 47				width: 60%;
 48				height: 500px;
 49				overflow-y: scroll;
 50				padding-top: 5%;
 51				padding-bottom: 5%;
 52				padding-right: 10%;
 53				padding-left: 10%;
 54				border-width: 3px;
 55				border-color: black;
 56				border-radius: 25px;
 57				margin-top: 15%;
 58				margin-bottom: 5%;
 59				margin-right: 10%;
 60				margin-left: 10%;
 61				z-index = -1;
 62			}
 63			p {
 64				font-family:"Times New Roman";
 65				font-size:20px;
 66			}
 67			a:link {
 68				font-size: 1em;
 69				font-weight: normal;
 70				color: white;  
 71				text-decoration:none;
 72				
 73			}
 74			a:visited {
 75				font-size: 1em;
 76				font-weight: normal;
 77				color: white;  
 78				text-decoration:none;
 79			}
 80			a:hover {
 81				font-size: 1.2em;
 82				font-weight: bold;
 83				color: white;  
 84				text-decoration:none;
 85			}
 86			a:active {
 87				font-size: 1.2em;
 88				font-weight: bold;
 89				color: white;  
 90				text-decoration:none;
 91			}
 92		</style>
 93	</head>
 94	
 95	<body background=1003background1.png>
 96		<div class="logo">
 97			<img src=MiddleburyPanther.jpg width="400px" height="145px">		
 98		</div>		
 99		<div class="header">
100			<?php
101				define('DB_SERVER','panther.cs.middlebury.edu');
102				define('DB_USERNAME','wschaaf');
103				define('DB_PASSWORD','wschaaf');
104				define('DB_DATABASE','wschaaf_Calendar');
105				$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die("Could not connect");
106				if(isset($_SESSION['User'])){
107					echo "<div class=headerText>Welcome ".$_SESSION['User']."</div>";
108					echo "<div class=headerText><a href='./events.php'>Home</a></div>";
109					echo "<div class=headerText><a href='./logout.php'>Logout</a></div>";					
110					echo "<form method='POST' action='insert1.php'> <input type='text' name='Search' >
111	<input type='submit' value='Search'> 
112	</form>";	
113					
114				}
115				else { 
116					//if session user is not set, show link to log in and to create user
117					$_SESSION['User'] = null;
118					echo "<div class=headerText><a href='./events.php'>Home</a></div>";					
119					echo "<div class=headerText><a href='./login.php'>Log In</a></div>";
120					echo "<form method='POST' action='insert1.php'> <input type='text' name='Search' >
121	<input type='submit' value='Search'> 
122	</form>";	
123				}
124			?>
125		</div>
126
127
128
129		<div class="main"> 
130			<?php 
131	//set up the connection to the database
132	define('DB_SERVER', 'panther.cs.middlebury.edu');
133	define('DB_USERNAME', 'wschaaf');
134	define('DB_PASSWORD', 'wschaaf');
135	define('DB_DATABASE', 'wschaaf_Calendar');
136	$search = htmlspecialchars($_POST[Search]);
137	$con = mysqli_connect(DB_SERVER, DB_USERNAME, DB_PASSWORD, DB_DATABASE) or die ("could not connect");
138	$sql="SELECT * FROM Events WHERE name LIKE '%$search%'";
139	if (!mysqli_query($con, $sql)) {
140		die('Error: ' . mysqli_error($con));
141	}
142	else {
143		//execute the SQL query
144		$result = mysqli_query($con,$sql);
145	}
146	while ($row = mysqli_fetch_array($result)) {
147		//print result
148		echo "<p>".$row['name']."</p>  </br>Location: ".$row['location']."  </br>Date: ".$row['date']."  </br> Time: ".$row['time']." </br> Genre: ".$row['genre']." </br> Description: ".$row['description']."</br> </br>";	 
149	}
150
151?>
152		</div>	
153
154
155