[ Avaa Bypassed ]




Upload:

Command:

hmhc3928@3.149.244.79: ~ $
<?php
	$page_title = "Add Location | CES Admin";
	include_once($_SERVER['DOCUMENT_ROOT'] . "/php/common_functions.php"); //common functions in the course registartion system
	include_once($_SERVER['DOCUMENT_ROOT'] . "/php/config.php"); //holds global config variables
 	check_if_authenticated('admin');//check if user is logged in
	include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/top-admin.php"); //get the HTML heading common to all pages in the CES admin module

?>

 <article class="ces-admin">
        <h2>CES Admin - Add Location</h2>


<?php
	include_once($_SERVER['DOCUMENT_ROOT'] . "/admin/php/nav-admin.php");
 	//opens connection to database

	$db = mysqli_connect($mysql_server, $user, $pass, $database);
?>


<?php 
	if (!isset($_POST['submit'])){ //if form has not been submitted yet
?>

		<form method='post' action='<?php echo $_SERVER['PHP_SELF'] ?>'>
			<div class="form-group">
				<label for='location_name'>Location Name:</label>
				<input class="form-control" type='text' name='location_name' maxlength='50'>
			</div>
			<div class="form-group">
				<label for='location_description'>Location Description:</label>
				<textarea class="form-control" style="height:auto; resize:none;" rows='5' name='location_description' wrap='soft'></textarea>
			</div>
			<div class="form-group">	
				<label for="address_line1">Address Line 1:</label>
				<input class="form-control" type='text' name='address_line1' maxlength='75'>
			</div>
			<div class="form-group">	
				<label for="address_line2">Address Line 2:</label>
				<input class="form-control" type='text' name='address_line2' maxlength='75'>
			</div>
			<div class="form-group">	
				<label for="city">City:</label>
				<input class="form-control ces-form-half" type='text' name='city' maxlength='50'>
			</div>
			<div class="form-group ces-form-one-quarter">
				<label for="province">Province:</label>	
				<?php provinces_select('province', ''); ?>
			</div>
			
			<div class="form-group ces-form-one-quarter">
				<label for="postal_code">Postal Code:</label>
				<input class="form-control" type='text' name='postal_code' maxlength='7' placeholder="A1B 2C3" pattern="[abceghjklmnprstvxyABCEGHJKLMNPRSTVXY][0-9][abceghjklmnprstvwxyzABCEGHJKLMNPRSTVWXYZ] ?[0-9][abceghjklmnprstvwxyzABCEGHJKLMNPRSTVWXYZ][0-9]"></td>
			</div>
			<div class="form-group ces-form-one-quarter">
				<label for="seats">Seats:</label>
				<input class="form-control" type='text' name='seats' maxlength='4' pattern="[0-9]{1,4}" title="Number of seats avalible.">
			</div>
			
			<input type='submit' name='submit' value="Add Location" class="btn btn-lg btn-block ces-green-btn">
			<input type='reset' name='reset' value="Reset Form" class="btn btn-lg btn-block ces-grey-btn">
			
		</form>

<?php
	} //end if

else { //form has been submitted, don't prompt for info; add form data to database and show what has been added

	//default $seats to 0 if a invalid number is entered
	if( !ctype_digit($_POST['seats']) || $_POST['seats'] < 0)
		$seats = 0;
	else
		$seats = $_POST['seats'];


		$location_name = htmlentities($_POST['location_name'], ENT_QUOTES);
		$location_description = htmlentities($_POST['location_description'], ENT_QUOTES);
		$address_line1 = htmlentities($_POST['address_line1'], ENT_QUOTES);
		$address_line2 = htmlentities($_POST['address_line2'], ENT_QUOTES);
		$city = htmlentities($_POST['city'], ENT_QUOTES);
		$postal_code = strtoupper(str_replace(" ","","$_POST[postal_code]"));


	$sql = "INSERT INTO ces_locations (location_name, location_description, address_line1, address_line2, city, province, postal_code, seats) VALUES (\"$location_name\", \"$location_description\", \"$address_line1\", \"$address_line2\", \"$city\", \"$_POST[province]\", \"$postal_code]\", $_POST[seats])";

	if(mysqli_query($db, $sql)){ //if the update is successful show the new entry
		echo "<p class='alert alert-block alert-success'>The location was successfully added.</p>";
		echo "<a href='index.php' class='btn btn-lg btn-block ces-green-btn'>Back to Location List</a>";
	} //end if

	else //else the update did not happen so output an error
    	print_sql_error('<br>Error - location submission failed when trying to do:', $sql);
	}//end else
	
?>

  </article>
    


  </section><!-- #middle-->

</div><!-- #wrapper --> 
 
<?php require_once $_SERVER['DOCUMENT_ROOT'].'/require/footer.php';?>

Filemanager

Name Type Size Permission Actions
add.php File 4.27 KB 0644
edit.php File 6.61 KB 0644
index.php File 2.69 KB 0644