Example #1
0
<?php

require_once "includes/session.php";
require_once "includes/connection.php";
require_once "includes/functions.php";
require_once "includes/form_functions.php";
confirm_staff_login();
if (isset($_POST['submit'])) {
    $name = mysql_para_prep($_POST['name']);
    $year = mysql_para_prep($_POST['year']);
    $content = mysql_para_prep($_POST['content']);
    $details = mysql_para_prep($_POST['details']);
    $winners = mysql_para_prep($_POST['winners']);
    $editorials = mysql_para_prep($_POST['editorials']);
    $finish = $_POST['finish'];
    $online = $_POST['online'];
    $allowedExts = array("gif", "jpeg", "jpg", "png");
    $temp = explode(".", $_FILES["file"]["name"]);
    $extension = end($temp);
    $file_name = $name . $year . "." . $extension;
    $pic_link = "img/" . $file_name;
    if (($_FILES["file"]["type"] == "image/gif" || $_FILES["file"]["type"] == "image/jpeg" || $_FILES["file"]["type"] == "image/jpg" || $_FILES["file"]["type"] == "image/pjpeg" || $_FILES["file"]["type"] == "image/x-png" || $_FILES["file"]["type"] == "image/png") && $_FILES["file"]["size"] < 1000000 && in_array($extension, $allowedExts)) {
        if ($_FILES["file"]["error"] > 0) {
            echo "Return Code: " . $_FILES["file"]["error"] . "<br>";
        } else {
            echo "Upload Image: " . $_FILES["file"]["name"] . "<br>";
            echo "Image Type: " . $_FILES["file"]["type"] . "<br>";
            echo "Image Size: " . $_FILES["file"]["size"] / 1024 . " kB<br>";
            echo "Temp file: " . $_FILES["file"]["tmp_name"] . "<br>";
            if (file_exists("upload/" . $_FILES["file"]["name"])) {
                echo $_FILES["file"]["name"] . " already exists. ";
Example #2
0
<?php

require_once "includes/session.php";
require_once "includes/connection.php";
require_once "includes/functions.php";
require_once "includes/form_functions.php";
confirm_staff_login();
if (isset($_POST['submit'])) {
    $name = mysql_para_prep($_POST["name"]);
    $event = $_POST["event"];
    $code = $_POST["code"];
    $content = mysql_para_prep($_POST["content"]);
    $year = date("Y");
    $query = "INSERT INTO questions (\r\n\t\t\t\tname, year_id, event_id, content, code\r\n\t\t\t\t) values (\r\n\t\t\t\t'{$name}', {$year}, {$event}, '{$content}', '{$code}'\r\n\t\t\t\t)";
    if (mysql_query($query, $connection)) {
        redirect_to("staff_area.php");
    } else {
        //echo mysql_error();
        echo "<p>Could not edit event</p>";
    }
}
require_once "includes/header.php";
?>
<div class="content clearfix">
   	<div class="chapter display clearfix">
   		<?php 
echo mysql_error();
?>
		<form action="new_problem.php" method="POST" class="bootstrap-frm" enctype="multipart/form-data">
		    <h1>Question Form 
		        <span>Please fill all the texts in the fields.</span>