Skip to content
Snippets Groups Projects
Commit 1dd612b4 authored by Kyle Powers's avatar Kyle Powers
Browse files

Adding voting page and functionality for voting.

parent fc454df0
Branches
No related tags found
No related merge requests found
......@@ -3,6 +3,13 @@ ini_set('display_errors',false);
// Sample configuration file for the ucomm webforms project
set_include_path(dirname(__FILE__).'/lib/php/'.PATH_SEPARATOR.get_include_path());
$con = mysql_connect("localhost","test","test");
if (!$con){
die('Could not connect: ' . mysql_error());
}else{
mysql_select_db("physics_voting", $con);
}
function myautoload($class)
{
$file = str_replace('_', '/', $class).'.php';
......
-- phpMyAdmin SQL Dump
-- version 3.3.7
-- http://www.phpmyadmin.net
--
-- Host: 127.0.0.1
-- Generation Time: Sep 30, 2010 at 03:38 PM
-- Server version: 5.1.50
-- PHP Version: 5.3.2
SET SQL_MODE="NO_AUTO_VALUE_ON_ZERO";
USE physics_voting;
/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */;
/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */;
/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */;
/*!40101 SET NAMES utf8 */;
--
-- Database: `surveys`
--
-- --------------------------------------------------------
--
-- Table structure for table `physics_opening2010`
--
CREATE TABLE IF NOT EXISTS `physics_opening2010` (
CREATE TABLE IF NOT EXISTS `entries` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`name` text COLLATE utf8_unicode_ci,
`email` text COLLATE utf8_unicode_ci,
`phone` text COLLATE utf8_unicode_ci,
`type` text COLLATE utf8_unicode_ci,
`proposal` text COLLATE utf8_unicode_ci,
`videourl` text COLLATE utf8_unicode_ci,
`votes` int(10),
`datesubmitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
CREATE TABLE IF NOT EXISTS `votes` (
`id` int(10) NOT NULL AUTO_INCREMENT,
`entries_id_fk` int(10),
`ip` VARCHAR(40),
`datesubmitted` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
PRIMARY KEY (`id`),
FOREIGN KEY(`entries_id_fk`) REFERENCES `entries`(`id`)
) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_unicode_ci AUTO_INCREMENT=1 ;
\ No newline at end of file
<?php
if (file_exists(dirname(__FILE__).'/../../../config.inc.php')) {
require_once dirname(__FILE__).'/../../../config.inc.php';
} else {
require_once dirname(__FILE__).'/../../../config.sample.php';
}
$ip=$_SERVER['REMOTE_ADDR'];
if($_POST['id']){
$id=$_POST['id'];
$id = mysql_escape_String($id);
$ip_sql=mysql_query("select ip from votes where ip='$ip'");
if(mysql_num_rows($ip_sql)==0){
$sql = "update entries set votes=votes+1 where id='$id'";
mysql_query($sql);
$sql_in = "insert into votes (entries_id_fk,ip) values ('$id','$ip')";
mysql_query($sql_in);
$result=mysql_query("select votes from entries where id='$id'");
$row=mysql_fetch_array($result);
echo $row['votes'] + " - Thanks for your vote!";
}else{
echo "Sorry, you have already voted.";
}
}
?>
\ No newline at end of file
......@@ -254,3 +254,4 @@ if (!empty($_POST)) {
</div>
</body>
</html>
<?php mysql_close($con);
\ No newline at end of file
<?php
/**
* TODO: Make page two collums, add graphic of iPad and the new building.
**/
if (file_exists(dirname(__FILE__).'/../../../config.inc.php')) {
require_once dirname(__FILE__).'/../../../config.inc.php';
} else {
require_once dirname(__FILE__).'/../../../config.sample.php';
}
if (!empty($_POST)) {
$mailer = new UNL_WDN_Emailer_Main();
$body .= "<strong>Name:</strong> " . $_POST['name'] . "<br/>";
$body .= "<strong>Phone Number:</strong> " . $_POST['phone'] . "<br/>";
$body .= "<strong>Email Address:</strong> " . $_POST['email'] . "<br/>";
$body .= "<strong>URL to video:</strong> " . $_POST['video'] . "<br/>";
$body .= "<strong>Type:</strong> " . $_POST['type'] . "<br/>";
$body .= "<strong>Proposal:</strong><br/>" . $_POST['proposal'] . "<br/>";
$mailer->html_body = $body;
$mailer->to_address = $sendToEmail;
$mailer->from_address = $sendFromEmail;
$mailer->subject = $emailSubject;
$mailer->send();
header('Location: thankyou.php');
exit();
}
?><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en">
<head>
<!--
Membership and regular participation in the UNL Web Developer Network
is required to use the UNL templates. Visit the WDN site at
http://wdn.unl.edu/. Click the WDN Registry link to log in and
register your unl.edu site.
All UNL template code is the property of the UNL Web Developer Network.
The code seen in a source code view is not, and may not be used as, a
template. You may not use this code, a reverse-engineered version of
this code, or its associated visual presentation in whole or in part to
create a derivative work.
This message may not be removed from any pages based on the UNL site template.
$Id: php.fixed.dwt.php 536 2009-07-23 15:47:30Z bbieber2 $
-->
<link rel="stylesheet" type="text/css" media="screen" href="css/physics.css" />
<link rel="stylesheet" type="text/css" media="screen" href="/wdn/templates_3.0/css/all.css" />
<link rel="stylesheet" type="text/css" media="print" href="/wdn/templates_3.0/css/print.css" />
<script type="text/javascript" src="/wdn/templates_3.0/scripts/all.js"></script>
<script type="text/javascript">
WDN.jQuery(function($) {
$(".vote").click(function() {
var parent = $(this);
$(this).fadeIn(200).html('...');
$.ajax({
type: "POST",
url: "castvote.php",
data: 'id=' + $(this).attr("id"),
cache: false,
success: function(html){
parent.html(html);
}
});
return false;
});
});
</script>
<?php virtual('/wdn/templates_3.0/includes/browserspecifics.html'); ?>
<?php virtual('/wdn/templates_3.0/includes/metanfavico.html'); ?>
<!-- TemplateBeginEditable name="doctitle" -->
<title>UNL | Department of Physics &amp; Astronomy | Jorgensen Hall Ribbon Cutting Proposal</title>
<!-- TemplateEndEditable --><!-- TemplateBeginEditable name="head" -->
<!-- Place optional header elements here -->
<!-- TemplateEndEditable -->
</head>
<body class="document">
<p class="skipnav"> <a class="skipnav" href="#maincontent">Skip Navigation</a> </p>
<div id="wdn_wrapper">
<div id="header"> <a href="http://www.unl.edu/" title="UNL website"><img src="/wdn/templates_3.0/images/logo.png" alt="UNL graphic identifier" id="logo" /></a>
<h1>University of Nebraska&ndash;Lincoln</h1>
<?php virtual('/wdn/templates_3.0/includes/wdnTools.html'); ?>
</div>
<div id="wdn_navigation_bar">
<div id="breadcrumbs">
<!-- WDN: see glossary item 'breadcrumbs' -->
<!-- TemplateBeginEditable name="breadcrumbs" -->
<ul>
<li><a href="http://www.unl.edu/" title="University of Nebraska&ndash;Lincoln">UNL</a></li>
<li><a href="http://ascweb.unl.edu/" title="University of Nebraska&ndash;Lincoln">Arts &amp; Sciences</a></li>
<li><a href="http://physics.unl.edu/" title="University of Nebraska&ndash;Lincoln">Physics &amp; Astronomy</a></li>
<li>Jorgensen Hall Ribbon Cutting Proposal</li>
</ul>
<!-- TemplateEndEditable --></div>
<div id="wdn_navigation_wrapper">
<div id="navigation"><!-- TemplateBeginEditable name="navlinks" -->
<?php include '../sharedcode/navigation.html'; ?>
<!-- TemplateEndEditable --></div>
</div>
</div>
<div id="wdn_content_wrapper">
<div id="titlegraphic"><!-- TemplateBeginEditable name="titlegraphic" --><h1>Jorgensen Hall Extreme Ribbon-Cutting Contest</h1>
<!-- TemplateEndEditable --></div>
<div id="pagetitle"><!-- TemplateBeginEditable name="pagetitle" --><!-- TemplateEndEditable --></div>
<div id="maincontent">
<!--THIS IS THE MAIN CONTENT AREA; WDN: see glossary item 'main content area' -->
<!-- TemplateBeginEditable name="maincontentarea" -->
<div style="float:left; width:620px; margin-right:20px;">
<ul class="wdn_tabs" style="width:620px;margin-bottom:16px;">
<li><a href="#contest">Contest</a></li>
<li><a href="#voting">Voting</a></li>
</ul>
<div class="wdn_tabs_content">
<div id="contest">
<h3 class="sec_header">If your idea makes the cut, you win an iPad!</h3>
<p>The University of Nebraska-Lincoln Physics Department invites proposals from students, faculty, staff, alumni and friends on how to add some physics-related drama to the ribbon-cutting dedication of Jorgensen Hall at 4 p.m. on Friday, Oct. 29. UNL Chancellor Harvey Perlman and special guest speaker Alan Heeger, a UNL alum and Nobel laureate, will be present for the ceremony.</p>
<p>
Anyone interested may submit a proposal for a way to ceremonially open the building by splitting apart a single ribbon, preferably using some aspect of physics, to make the celebration more interesting than is possible using only ribbon and scissors. The creator of the winning proposal will receive <a href="http://marketplace.unl.edu/computershop/electronics/ipads/16gb-ipad-wifi.html" title="iPad at the UNL Computer Shop">a 16GB iPad WiFi"</a> or dollar value equivalent in merchandise from the <a href="http://marketplace.unl.edu/computershop/">UNL Computer and Phone Shop</a>.
</p>
<p><strong><a href="index.php#submit" title="submit a proposal for the ribbon cutting">Submit your proposal now!</a></strong></p>
</div>
<div id="voting">
<h3 class="sec_header">Voting</h3>
<?php
$sql=mysql_query("SELECT * FROM entries ORDER BY RAND() LIMIT 3");
while($row=mysql_fetch_array($sql)){
$id=$row['id'];
$name=$row['name'];
$proposal=$row['proposal'];
$votes=$row['votes'];
$videourl=$row['videourl'];
?>
<div>
<p>
<?php echo $name; ?> - <?php echo $votes; ?> votes<br/>
<?php echo $proposal; ?><br/>
<a id="videolink<?php echo $id; ?>" href="#">Watch Video</a> | <a href="#" class="vote" id="<?php echo $id; ?>">Click here to vote for <?php echo $name; ?></a>
</p>
</div>
<div class='hidden'>
<div id='video<?php echo $id; ?>' style='padding:10px; background:#fff;'>
<object width="480" height="385">
<param name="movie" value="<?php echo $videourl ?>?fs=1&amp;hl=en_US&autoplay=1"></param>
<param name="allowFullScreen" value="true"></param>
<param name="allowscriptaccess" value="always"></param>
<param name="autoplay" value="true"></param>
<embed src="<?php echo $videourl ?>?fs=1&hl=en_US&autoplay=1" type="application/x-shockwave-flash"
allowscriptaccess="always" allowfullscreen="true" width="480" height="385"></embed>
</object>
</div>
</div>
<script type="text/javascript">
WDN.jQuery("#videolink<?php echo $id; ?>").colorbox({inline:true, href:"#video<?php echo $id; ?>", title:"Video by <?php echo $name; ?>"});
</script>
<?php } ?>
</div>
</div>
</div>
<div style="width:300px; float:right;">
<a href="index.php#submit" title="submit a proposal for the ribbon cutting"><img src="images/iPad_Jorgensen.jpg" alt="Jorgensen ribbon cutting" /></a><br />
<a href="http://marketplace.unl.edu/computershop/" title="go to the Computer Shop on UNL Marketplace"><img src="images/compshop.jpg" alt="UNL Computer shop" /></a>
</div>
<!-- TemplateEndEditable -->
<div class="clear"></div>
<?php virtual('/wdn/templates_3.0/includes/noscript.html'); ?>
<!--THIS IS THE END OF THE MAIN CONTENT AREA.-->
</div>
<div id="footer">
<div id="footer_floater"></div>
<div class="footer_col">
<?php virtual('/wdn/templates_3.0/includes/feedback.html'); ?>
</div>
<div class="footer_col"><!-- TemplateBeginEditable name="leftcollinks" -->
<?php include '../sharedcode/relatedLinks.html'; ?>
<!-- TemplateEndEditable --></div>
<div class="footer_col"><!-- TemplateBeginEditable name="contactinfo" -->
<?php include '../sharedcode/footerContactInfo.html'; ?>
<!-- TemplateEndEditable --></div>
<div class="footer_col">
<?php virtual('/wdn/templates_3.0/includes/socialmediashare.html'); ?>
</div>
<!-- TemplateBeginEditable name="optionalfooter" --> <!-- TemplateEndEditable -->
<div id="wdn_copyright"><!-- TemplateBeginEditable name="footercontent" -->
<?php include '../sharedcode/footer.html'; ?>
<!-- TemplateEndEditable -->
<?php virtual('/wdn/templates_3.0/includes/wdn.html'); ?>
| <a href="http://validator.unl.edu/check/referer">W3C</a> | <a href="http://jigsaw.w3.org/css-validator/check/referer?profile=css3">CSS</a> <a href="http://www.unl.edu/" title="UNL Home" id="wdn_unl_wordmark"><img src="/wdn/templates_3.0/css/footer/images/wordmark.png" alt="UNL's wordmark" /></a> </div>
</div>
</div>
<div id="wdn_wrapper_footer"> </div>
</div>
</body>
</html>
<?php mysql_close($con);
\ No newline at end of file
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment