survey_seahorse

Software Engineering Project - Fall 2018
Log | Files | Refs | README

commit 31c982a22c1897ad12ac88d223e0431811a775fa
parent 20a7cbb36904822f1b1d948a3ecc523ec8991180
Author: John Kubach <johnkubach@gmail.com>
Date:   Mon, 10 Dec 2018 15:31:00 -0500

add website / database

Diffstat:
Aseahorse/answer_numeric.frm | 0
Aseahorse/answer_numeric.ibd | 0
Aseahorse/db.opt | 2++
Aseahorse/question.frm | 0
Aseahorse/question.ibd | 0
Aseahorse/survey.frm | 0
Aseahorse/survey.ibd | 0
Aseahorse/user.frm | 0
Aseahorse/user.ibd | 0
Awebsite/createsurvey.php | 18++++++++++++++++++
Awebsite/findsurvey.php | 14++++++++++++++
Awebsite/index.php | 17+++++++++++++++++
Awebsite/login.php | 13+++++++++++++
Awebsite/logout.php | 8++++++++
Awebsite/profile.php | 20++++++++++++++++++++
Awebsite/questions.php | 12++++++++++++
Awebsite/res/.login-user.php.swp | 0
Awebsite/res/.new-survey.php.swp | 0
Awebsite/res/img/ocean.jpg | 0
Awebsite/res/img/seahorse.png | 0
Awebsite/res/login-user.php | 46++++++++++++++++++++++++++++++++++++++++++++++
Awebsite/res/new-survey.php | 56++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Awebsite/res/register.php | 46++++++++++++++++++++++++++++++++++++++++++++++
Awebsite/res/submit-questions.php | 22++++++++++++++++++++++
Awebsite/res/submit-survey.php | 28++++++++++++++++++++++++++++
Awebsite/res/txt/adjectives.txt | 912+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Awebsite/res/txt/creatures.txt | 26++++++++++++++++++++++++++
Awebsite/results.php | 3+++
Awebsite/session.php | 16++++++++++++++++
Awebsite/signup.php | 11+++++++++++
Awebsite/style.css | 87+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Awebsite/success.php | 16++++++++++++++++
Awebsite/takesurvey.php | 66++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
33 files changed, 1439 insertions(+), 0 deletions(-)

diff --git a/seahorse/answer_numeric.frm b/seahorse/answer_numeric.frm Binary files differ. diff --git a/seahorse/answer_numeric.ibd b/seahorse/answer_numeric.ibd Binary files differ. diff --git a/seahorse/db.opt b/seahorse/db.opt @@ -0,0 +1,2 @@ +default-character-set=latin1 +default-collation=latin1_swedish_ci diff --git a/seahorse/question.frm b/seahorse/question.frm Binary files differ. diff --git a/seahorse/question.ibd b/seahorse/question.ibd Binary files differ. diff --git a/seahorse/survey.frm b/seahorse/survey.frm Binary files differ. diff --git a/seahorse/survey.ibd b/seahorse/survey.ibd Binary files differ. diff --git a/seahorse/user.frm b/seahorse/user.frm Binary files differ. diff --git a/seahorse/user.ibd b/seahorse/user.ibd Binary files differ. diff --git a/website/createsurvey.php b/website/createsurvey.php @@ -0,0 +1,18 @@ +<html> +<h2> Create Survey </h2> +<form class="create-survey-form" action="res/new-survey.php" method="POST"> + +<input type="text" name="title" placeholder="My Amazing Survey"> <br> +<input type="text" name="description" placeholder="A great survey"> <br> +<input type="radio" name="type" value="00"> Numeric (1 - 10) <br> +<input type="radio" name="type" value="01"> Yes / No <br> +<input type="radio" name="type" value="10"> Text <br> +<input type="text" name="number" placeholder="5"> <br> +<input type="date" name="expire"> +<input type="radio" name="once" value="1"> one shot <br> +<input type="radio" name="once" value="0" checked> multi + +<button type="submit" name="submit">Create Survey</button> + +</form> +</html> diff --git a/website/findsurvey.php b/website/findsurvey.php @@ -0,0 +1,14 @@ +<?php session_start(); +include_once 'config.php'; +$sql = "SELECT access_code FROM survey ORDER BY RAND() LIMIT 1;"; +$result = mysqli_query($connect, $sql); +$rand_code = mysqli_fetch_assoc($result); +?> +<h2> Find Survey </h2> +<form class ="find-survey-form" action="takesurvey.php" method="POST"> +<input type="text" name="survey-code" placeholder="Survey Code"> +<button type="submit" name="submit">Find Survey</button> +<?php +echo "<p> Looking for a survey? Try ", $rand_code['access_code'], "</p>"; + +?> diff --git a/website/index.php b/website/index.php @@ -0,0 +1,17 @@ +<?php +ini_set('display_errors', 'On'); +error_reporting(E_ALL | E_STRICT); +session_start(); +include_once 'config.php'; +$sql = "SELECT question_content FROM question ORDER BY RAND() LIMIT 1;"; +$result = mysqli_query($connect, $sql) or die(mysqli_error($connect)); +$q = mysqli_fetch_assoc($result); +?> +<h1> Survey Seahorse </h1> +<h3> Random Question: <?php echo $q['question_content']; ?> </h3> +<a href="login.php"> Login </a> <br> +<a href="signup.php"> Register </a> <br> +<a href="profile.php"> Profile </a> <br> +<a href="createsurvey.php"> Create Survey </a> <br> +<a href="findsurvey.php"> Find a Survey </a> <br> +<a href="logout.php"> Logout </a> <br> diff --git a/website/login.php b/website/login.php @@ -0,0 +1,13 @@ +<?php +session_start(); +?> +<html> +<h2> Sign In</h2> +<form class="signin-form" action="res/login-user.php" method="POST"> + +<input type="text" name="username" placeholder="User Name"> +<input type="text" name="password" placeholder="Password"> +<button type="submit" name="submit">Sign In</button> + +</form> +</html> diff --git a/website/logout.php b/website/logout.php @@ -0,0 +1,8 @@ +<?php +session_start(); +unset($_SESSION["uid"]); +unset($_SESSION["email"]); +unset($_SESSION["username"]); +unset($_SESSION["date"]); +header("Location: login.php"); +?> diff --git a/website/profile.php b/website/profile.php @@ -0,0 +1,20 @@ +<?php + +session_start(); +include_once 'config.php'; + +$user = $_SESSION['username']; +$email = $_SESSION['email']; +$uid = $_SESSION['uid']; +$date = $_SESSION['date']; + +$sql = "SELECT title FROM survey WHERE survey_id IN (SELECT survey_id FROM answer_numeric WHERE user_id=$uid);"; + $result = mysqli_query($connect, $sql); + $surveys_taken = mysqli_fetch_assoc($result); + echo "Surveys that ", $user, " has taken: ", $surveys_taken['title'], "<br>"; +?> + + <h1> <?php echo $user; ?> </h1> + <h1> <?php echo $email; ?> </h1> + <h1> <?php echo $uid; ?> </h1> + <h1> <?php echo $date; ?> </h1> diff --git a/website/questions.php b/website/questions.php @@ -0,0 +1,12 @@ +<?php +session_start(); + +$questions = $_SESSION['questions']; + echo "<form method = 'POST' action = 'res/submit-questions.php'>"; + for($counter = 0; $counter < $questions; $counter++) + { + echo "<input type = 'text' name = 'questions[]' class = 'questions'/><br/>"; + } + echo "<input type = 'submit' value = 'SEND'/>"; + echo "</form>"; +?> diff --git a/website/res/.login-user.php.swp b/website/res/.login-user.php.swp Binary files differ. diff --git a/website/res/.new-survey.php.swp b/website/res/.new-survey.php.swp Binary files differ. diff --git a/website/res/img/ocean.jpg b/website/res/img/ocean.jpg Binary files differ. diff --git a/website/res/img/seahorse.png b/website/res/img/seahorse.png Binary files differ. diff --git a/website/res/login-user.php b/website/res/login-user.php @@ -0,0 +1,46 @@ +<?php + +session_start(); + +if (isset($_POST['submit'])) { + include '../config.php'; + + $username = mysqli_real_escape_string($connect, $_POST['username']); + $password = mysqli_real_escape_string($connect, $_POST['password']); + + if (empty($username) || empty($password)) { + header("Location: ../index.php?login=error"); + exit(); + + } else { + $sql = "SELECT * FROM user WHERE username='$username'"; + $result = mysqli_query($connect, $sql); + $check = mysqli_num_rows($result); + + if ($check < 1) { + header("Location: ../index.php?login=error"); + exit(); + } else { + if ($row = mysqli_fetch_assoc($result)) { + $checkHash = password_verify($password, $row['password']); + if ($checkHash == false) { + header("Location: ../index.php?login=errorpass"); + exit(); + } elseif ($checkHash == true) { + $_SESSION['uid'] = $row['user_id']; + $_SESSION['email'] = $row['email']; + $_SESSION['username'] = $row['username']; + $_SESSION['date'] = $row['registration_date']; + header("Location: ../index.php?login=success"); + exit(); + } + } + } + } +} else { + header("Location: ../index.php?login=error"); + exit(); + +} + +?> diff --git a/website/res/new-survey.php b/website/res/new-survey.php @@ -0,0 +1,56 @@ +<?php +ini_set('display_errors', 'On'); +error_reporting(E_ALL | E_STRICT); + +session_start(); + +if (isset($_POST['submit'])) { + include_once '../config.php'; + + $title = mysqli_real_escape_string($connect, $_POST['title']); + $description = mysqli_real_escape_string($connect, $_POST['description']); + $type = mysqli_real_escape_string($connect, $_POST['type']); + $number_questions = mysqli_real_escape_string($connect, $_POST['number']); + $expire_date = mysqli_real_escape_string($connect, $_POST['expire']); + $one_shot = mysqli_real_escape_string($connect, $_POST['once']); + + $uid = $_SESSION['uid']; + $user = $_SESSION['username']; + + if (empty($title)) { + header("Location: ../createsurvey.php?item=empty"); + exit(); + } else { + $adj_file = file("txt/adjectives.txt"); + $adj_name = $adj_file[array_rand($adj_file)]; + $adj = str_replace("\n", "", $adj_name); + $creature_file = file("txt/creatures.txt"); + $creature_name = $creature_file[array_rand($creature_file)]; + $creature = str_replace("\n", "", $creature_name); + $code = $adj." ".$creature; + $sql_expire = date("Y-m-d", strtotime($expire_date)); + $date = date("Y-m-d"); + $sql = "INSERT INTO survey (user_id, access_code, title, author, description, + type, number_questions, creation_date, expiration_date, + one_shot) + VALUES ($uid, '$code', '$title', '$user', '$description', + $type, '$number_questions', '$date', '$sql_expire', + $one_shot);"; + + mysqli_query($connect, $sql) or die(mysqli_error($connect)); + + $sql ="SELECT * FROM survey WHERE access_code='$code'"; + $result = mysqli_query($connect, $sql); + $row = mysqli_fetch_assoc($result); + + $_SESSION['sid'] = $row['survey_id']; + $_SESSION['code'] = $row['access_code']; + $_SESSION['title'] = $row['title']; + $_SESSION['description'] = $row['description']; + $_SESSION['questions'] = $row['number_questions']; + header("Location: ../questions.php"); + exit(); + } +} + +?> diff --git a/website/res/register.php b/website/res/register.php @@ -0,0 +1,46 @@ +<?php +ini_set('display_errors', 'On'); +error_reporting(E_ALL | E_STRICT); + +if (isset($_POST['submit'])) { + include_once '../config.php'; + + $email = mysqli_real_escape_string($connect, $_POST['email']); + $username = mysqli_real_escape_string($connect, $_POST['username']); + $password = mysqli_real_escape_string($connect, $_POST['password']); + + if (empty($email) || empty($username) || empty($password)) { + header("Location: ../signup.php?signup=empty"); + exit(); + } else { + if (!filter_var($email, FILTER_VALIDATE_EMAIL)) { + header("Location: ../signup.php?signup=email"); + exit(); + } else { + $sql = "SELECT * FROM user WHERE username = '$username'"; + $result = mysqli_query($connect, $sql); + $check = mysqli_num_rows($result); + + if ($check > 0) { + header("Location: ../signup.php?signup=email"); + exit(); + } else { + $hashPass = password_hash($password, PASSWORD_DEFAULT); + $date = date("Y-m-d H:i:s"); + $sql = "INSERT INTO user (email, username, password, + registration_date) + VALUES ('$email', '$username', '$hashPass', '$date');"; + + mysqli_query($connect, $sql); + header("Location: ../signup.php?signup=success"); + exit(); + } + } + } + +} else { + header("Location: ../signup.php"); + exit(); +} + +?> diff --git a/website/res/submit-questions.php b/website/res/submit-questions.php @@ -0,0 +1,22 @@ +<?php +ini_set('display_errors', 'On'); +error_reporting(E_ALL | E_STRICT); +session_start(); +include_once '../config.php'; + $questions = array(); + + $survey_id = $_SESSION['sid']; + $questions = $_POST['questions']; + + for($counter = 0; $counter < sizeof($questions); $counter++) + { + $q = $questions[$counter]; + echo "Question #".($counter + 1).": ".$questions[$counter]."<br />"; + $sql = "INSERT INTO question (survey_id, question_number, question_content) + VALUES ('$survey_id', $counter + 1, '$q');"; + mysqli_query($connect, $sql) or die(mysqli_error($connect)); + + } + header("Location: ../success.php"); + exit(); +?> diff --git a/website/res/submit-survey.php b/website/res/submit-survey.php @@ -0,0 +1,28 @@ +<?php +ini_set('display_errors', 'On'); +error_reporting(E_ALL | E_STRICT); +session_start(); +include_once '../config.php'; +$answers = array(); + +$user = $_SESSION['uid']; +$survey_id = $_SESSION['sid']; +$answers = $_POST['answers']; + +for($counter = 0; $counter < sizeof($answers); $counter++) +{ + $q = $answers[$counter]; + echo "Answer #".($counter + 1).": ".$answers[$counter]."<br />"; + $sql = "INSERT INTO answer_numeric (user_id, survey_id, question_number, answer) + VALUES ('$user', '$survey_id', $counter + 1, $q);"; + mysqli_query($connect, $sql) or die(mysqli_error($connect)); + + $getsql = "SELECT question_content from question where survey_id=$survey_id and question_number=$counter+1;"; + $result = mysqli_query($connect, $getsql); + $question = mysqli_fetch_assoc($result); + echo "For Question: ", $question['question_content'], ", you answered: ", $answers[$counter], "<br>"; + +} + echo "<a href='../index.php'> Home </a>"; +exit(); +?> diff --git a/website/res/txt/adjectives.txt b/website/res/txt/adjectives.txt @@ -0,0 +1,912 @@ +quizzical +highfalutin +dynamic +wakeful +cheerful +thoughtful +cooperative +questionable +abundant +uneven +yummy +juicy +vacuous +concerned +young +sparkling +abhorrent +sweltering +late +macho +scrawny +friendly +kaput +divergent +busy +charming +protective +premium +puzzled +waggish +rambunctious +puffy +hard +fat +sedate +yellow +resonant +dapper +courageous +vast +cool +elated +wary +bewildered +level +wooden +ceaseless +tearful +cloudy +gullible +flashy +trite +quick +nondescript +round +slow +spiritual +brave +tenuous +abstracted +colossal +sloppy +obsolete +elegant +fabulous +vivacious +exuberant +faithful +helpless +odd +sordid +blue +imported +ugly +ruthless +deeply +eminent +reminiscent +rotten +sour +volatile +succinct +judicious +abrupt +learned +stereotyped +evanescent +efficacious +festive +loose +torpid +condemned +selective +strong +momentous +ordinary +dry +great +ultra +ahead +broken +dusty +piquant +creepy +miniature +periodic +equable +unsightly +narrow +grieving +whimsical +fantastic +kindhearted +miscreant +cowardly +cloistered +marked +bloody +chunky +undesirable +oval +nauseating +aberrant +stingy +standing +distinct +illegal +angry +faint +rustic +few +calm +gorgeous +mysterious +tacky +unadvised +greasy +minor +loving +melodic +flat +wretched +clever +barbarous +pretty +endurable +handsomely +unequaled +acceptable +symptomatic +hurt +tested +long +warm +ignorant +ashamed +excellent +known +adamant +eatable +verdant +meek +unbiased +rampant +somber +cuddly +harmonious +salty +overwrought +stimulating +beautiful +crazy +grouchy +thirsty +joyous +confused +terrible +high +unarmed +gabby +wet +sharp +wonderful +magenta +tan +huge +productive +defective +chilly +needy +imminent +flaky +fortunate +neighborly +hot +husky +optimal +gaping +faulty +guttural +massive +watery +abrasive +ubiquitous +aspiring +impartial +annoyed +billowy +lucky +panoramic +heartbreaking +fragile +purring +wistful +burly +filthy +psychedelic +harsh +disagreeable +ambiguous +short +splendid +crowded +light +yielding +hypnotic +dispensable +deserted +nonchalant +green +puny +deafening +classy +tall +typical +exclusive +materialistic +mute +shaky +inconclusive +rebellious +doubtful +telling +unsuitable +woebegone +cold +sassy +arrogant +perfect +adhesive +industrious +crabby +curly +voiceless +nostalgic +better +slippery +willing +nifty +orange +victorious +ritzy +wacky +vigorous +spotless +good +powerful +bashful +soggy +grubby +moaning +placid +permissible +half +towering +bawdy +measly +abaft +delightful +goofy +capricious +nonstop +addicted +acoustic +furtive +erratic +heavy +square +delicious +needless +resolute +innocent +abnormal +hurried +awful +impossible +aloof +giddy +large +pointless +petite +jolly +boundless +abounding +hilarious +heavenly +honorable +squeamish +red +phobic +trashy +pathetic +parched +godly +greedy +pleasant +small +aboriginal +dashing +icky +bumpy +laughable +hapless +silent +scary +shaggy +organic +unbecoming +inexpensive +wrong +repulsive +flawless +labored +disturbed +aboard +gusty +loud +jumbled +exotic +vulgar +threatening +belligerent +synonymous +encouraging +fancy +embarrassed +clumsy +fast +ethereal +chubby +high-pitched +plastic +open +straight +little +ancient +fair +psychotic +murky +earthy +callous +heady +lamentable +hallowed +obtainable +toothsome +oafish +gainful +flippant +tangy +tightfisted +damaging +utopian +gaudy +brainy +imperfect +shiny +fanatical +snotty +relieved +shallow +foamy +parsimonious +gruesome +elite +wide +kind +bored +tangible +depressed +boring +screeching +outrageous +determined +picayune +glossy +historical +staking +curious +gigantic +wandering +profuse +vengeful +glib +unaccountable +frightened +outstanding +chivalrous +workable +modern +swanky +comfortable +gentle +substantial +brawny +curved +nebulous +boorish +afraid +fierce +efficient +lackadaisical +recondite +internal +absorbed +squealing +frail +thundering +wanting +cooing +axiomatic +debonair +boiling +tired +numberless +flowery +mushy +enthusiastic +proud +upset +hungry +astonishing +deadpan +prickly +mammoth +absurd +clean +jittery +wry +entertaining +literate +lying +uninterested +aquatic +super +languid +cute +absorbing +scattered +brief +halting +bright +fuzzy +lethal +scarce +aggressive +obsequious +fine +giant +holistic +pastoral +stormy +quaint +nervous +wasteful +grotesque +loutish +abiding +unable +black +dysfunctional +knowledgeable +truculent +various +luxuriant +shrill +spiffy +guarded +colorful +misty +spurious +freezing +glamorous +famous +new +instinctive +nasty +exultant +seemly +tawdry +maniacal +wrathful +shy +nutritious +idiotic +worried +bad +stupid +ruddy +wholesale +naughty +thoughtless +futuristic +available +slimy +cynical +fluffy +plausible +nasty +tender +changeable +smiling +oceanic +satisfying +steadfast +ugliest +crooked +subsequent +fascinated +woozy +teeny +quickest +moldy +uppity +sable +horrible +silly +ad hoc +numerous +berserk +wiry +knowing +lazy +childlike +zippy +fearless +pumped +weak +tacit +weary +rapid +precious +smoggy +swift +lyrical +steep +quack +direful +talented +hesitant +fallacious +ill +quarrelsome +quiet +flipped-out +didactic +fluttering +glorious +tough +sulky +elfin +abortive +sweet +habitual +supreme +hollow +possessive +inquisitive +adjoining +incandescent +lowly +majestic +bizarre +acrid +expensive +aback +unusual +foolish +jobless +capable +damp +political +dazzling +erect +Early +immense +hellish +omniscient +reflective +lovely +incompetent +empty +breakable +educated +easy +devilish +assorted +decorous +jaded +homely +dangerous +adaptable +coherent +dramatic +tense +abject +fretful +troubled +diligent +solid +plain +raspy +irate +offbeat +healthy +melted +cagey +many +wild +venomous +animated +alike +youthful +ripe +alcoholic +sincere +teeny-tiny +lush +defeated +zonked +foregoing +dizzy +frantic +obnoxious +funny +damaged +grandiose +spectacular +maddening +defiant +makeshift +strange +painstaking +merciful +madly +clammy +itchy +difficult +clear +used +temporary +abandoned +null +rainy +evil +alert +domineering +amuck +rabid +jealous +robust +obeisant +overt +enchanting +longing +cautious +motionless +bitter +anxious +craven +breezy +ragged +skillful +quixotic +knotty +grumpy +dark +draconian +alluring +magical +versed +humdrum +accurate +ludicrous +sleepy +envious +lavish +roasted +thinkable +overconfident +roomy +painful +wee +observant +old-fashioned +drunk +royal +likeable +adventurous +eager +obedient +attractive +x-rated +spooky +poised +righteous +excited +real +abashed +womanly +ambitious +lacking +testy +big +gamy +early +auspicious +blue-eyed +discreet +nappy +vague +helpful +nosy +perpetual +disillusioned +overrated +gleaming +tart +soft +agreeable +therapeutic +accessible +poor +gifted +old +humorous +flagrant +magnificent +alive +understood +economic +mighty +ablaze +racial +tasteful +purple +broad +lean +legal +witty +nutty +icy +feigned +redundant +adorable +apathetic +jumpy +scientific +combative +worthless +tasteless +voracious +jazzy +uptight +utter +hospitable +imaginary +finicky +shocking +dead +noisy +shivering +subdued +rare +zealous +demonic +ratty +snobbish +deranged +muddy +whispering +credible +hulking +fertile +tight +abusive +functional +obscene +thankful +daffy +smelly +lively +homeless +secretive +amused +lewd +mere +agonizing +sad +innate +sneaky +noxious +illustrious +alleged +cultured +tame +macabre +lonely +mindless +low +scintillating +statuesque +decisive +rhetorical +hysterical +happy +earsplitting +mundane +spicy +overjoyed +taboo +peaceful +forgetful +elderly +upbeat +squalid +warlike +dull +plucky +handsome +groovy +absent +wise +romantic +invincible +receptive +smooth +different +tiny +cruel +dirty +mature +faded +tiresome +wicked +average +panicky +detailed +juvenile +scandalous +steady +wealthy +deep +sticky +jagged +wide-eyed +tasty +disgusted +garrulous +graceful +tranquil +annoying +hissing +noiseless +selfish +onerous +lopsided +ossified +penitent +malicious +aromatic +successful +zany +evasive +wet +naive +nice +uttermost +brash +muddled +energetic +accidental +silky +guiltless +important +drab +aware +skinny +careful +rightful +tricky +sore +rich +blushing +stale +daily +watchful +uncovered +rough +fresh +hushed +rural diff --git a/website/res/txt/creatures.txt b/website/res/txt/creatures.txt @@ -0,0 +1,26 @@ +barnacle +barracuda +cod +conch +dolphin +eel +fish +herring +jellyfish +krill +manatee +mussel +narwhal +nautillus +octopus +oyster +prawn +seahorse +shark +sponge +squid +swordfish +turtle +unicornfish +whale +zooplankton diff --git a/website/results.php b/website/results.php @@ -0,0 +1,3 @@ +<?php +session_start(); +include_once 'config.php'; diff --git a/website/session.php b/website/session.php @@ -0,0 +1,16 @@ +<?php + include('config.php'); + session_start(); + + $user_check = $_SESSION['login_user']; + + $ses_sql = mysql_query($db,"select username from user where username = '$user_check' "); + + $row = mysql_fetch_array($ses_sql,MYSQL_ASSOC); + + $login_session = $row['username']; + + if(!isset($_SESSION['login_user'])){ + header("location:login.php"); + } +?> diff --git a/website/signup.php b/website/signup.php @@ -0,0 +1,11 @@ +<html> +<h2> Signup </h2> +<form class="signup-form" action="res/register.php" method="POST"> + +<input type="text" name="email" placeholder="Email"> +<input type="text" name="username" placeholder="User Name"> +<input type="text" name="password" placeholder="Password"> +<button type="submit" name="submit">Sign Up</button> + +</form> +</html> diff --git a/website/style.css b/website/style.css @@ -0,0 +1,87 @@ +@import url('https://fonts.googleapis.com/css?family=Raleway'); +@import url('https://fonts.googleapis.com/css?family=Oswald'); + +body { + background: #fff; + padding: 0px; + margin: 0px; + font-family: 'Oswald', sans-serif; + color: white; + font-size: 16px; + background: url(ocean.jpg) fixed 50% 50%; + background-color: rgb(66,173, 244); + background-position: left; + background-size: cover; + } + .box_title{ + font-family: 'Raleway', sans-serif; + color: #F9F3F4; + font-size: 250%; + margin-bottom: 50px; + max-width: 500px; + margin: 0 auto; + text-align: center; + } + + input, button { + font-family: 'Nunito', sans-serif; + font-weight: 700; + } + + .main-div, .loggedin-div { + width: 20%; + margin: 0px auto; + margin-top: 150px; + padding: 20px; + display: none; + background: rgba(0,0,0,.8); + padding: 40px; + border-radius: 10px; /*Rounded edges*/ + } + + .main-div input { + display: block; + border: 1px solid #ccc; + border-radius: 5px; + background: #fff; + padding: 15px; + outline: none; + width: 100%; + margin-bottom: 20px; + transition: 0.3s; + -webkit-transition: 0.3s; + -moz-transition: 0.3s; + } + + .main-div input:focus { + border: 1px solid #777; + } + + .main-div button, .loggedin-div button { + background: #5d8ffc; + color: #fff; + border: 1px solid #5d8ffc; + border-radius: 5px; + padding: 15px; + display: block; + width: 100%; + transition: 0.3s; + -webkit-transition: 0.3s; + -moz-transition: 0.3s; + } + + .main-div button:hover, .loggedin-div button:hover { + background: #fff; + color: #5d8ffc; + border: 1px solid #5d8ffc; + cursor: pointer; + } + + .img{ + margin-left: auto; + margin-right: inherit; + /*transform: translateX(20%);*/ + margin-bottom: 50px; + animation-delay: 5; + animation: ease-in; + } diff --git a/website/success.php b/website/success.php @@ -0,0 +1,16 @@ +<?php +session_start(); +$code = $_SESSION['code']; +$title = $_SESSION['title']; +?> +<h1> Success </h1> +<?php +echo $title, " has been created."; +echo "Use access code ", $code; +unset($_SESSION['sid']); +unset($_SESSION['code']); +unset($_SESSION['title']); +unset($_SESSION['description']); +unset($_SESSION['questions']); +?> +<a href="index.php"> Home </a> diff --git a/website/takesurvey.php b/website/takesurvey.php @@ -0,0 +1,66 @@ +<?php +ini_set('display_errors', 'On'); +error_reporting(E_ALL | E_STRICT); + +session_start(); +include_once 'config.php'; + +$code = mysqli_real_escape_string($connect, $_POST['survey-code']); + +if (empty($code)) { + header("Location: ../findsurvey.php?find=error"); + exit(); +} else { + $sql = "SELECT * FROM survey WHERE access_code='$code'"; + $result = mysqli_query($connect, $sql); + $check = mysqli_num_rows($result); + + if ($check < 1) { + header("Location: ../findsurvey.php?find=error"); + exit(); + } else { + $row = mysqli_fetch_assoc($result); + $_SESSION['sid'] = $row['survey_id']; + $sid = $row['survey_id']; + $title = $row['title']; + $number_questions = $row['number_questions']; + + echo "<form method = 'POST' action = 'res/submit-survey.php'>"; + echo "<h1> $title </h1> <br>"; + for($counter = 0; $counter < $number_questions; $counter++) + { + $sql = "SELECT question_content FROM question WHERE survey_id=$sid and question_number=$counter+1;"; + $result = mysqli_query($connect, $sql); + $q = mysqli_fetch_assoc($result); + echo $q['question_content'], "<br>"; + echo " <select name = 'answers[]'> + <option value='1'>1</option> + <option value='2'>2</option> + <option value='3'>3</option> + <option value='4'>4</option> + <option selected='selected' value='5'>5</option> + <option value='6'>6</option> + <option value='7'>7</option> + <option value='8'>8</option> + <option value='9'>9</option> + <option value='10'>10</option> + </select> "; + // echo "<input type='range' name = 'answers[]' min='1' max='10' value='5' step='1' class='slider' id='answerSlide'> <br>"; + echo "<p> <span id='demo'</span> </p>"; + } + echo "<input type = 'submit' value = 'SEND'/>"; + echo "</form>"; + } +} + + +?> +<script> +var slider = document.getElementById("answerSlide"); +var output = document.getElementById("demo"); +output.innerHTML = slider.value; + +slider.oninput = function() { + output.innerHTML = this.value; +} +</script>