ProductsLogo
LogoStudy Documents
LogoAI Grader
LogoAI Answer
LogoAI Code Checker
LogoPlagiarism Checker
LogoAI Paraphraser
LogoAI Quiz
LogoAI Detector
PricingBlogAbout Us
logo

Result Page with Polls and Questions Count

Verified

Added on  2019/09/21

|18
|3297
|356
Report
AI Summary
The assignment content appears to be a PHP-based online poll system. It involves the creation of a result page (result.php) that displays the questions, their corresponding polls counts, and a bar chart using Plotly. The script connects to a database, retrieves data, and calculates the number of polls for each question. The page also includes navigation links for users.

Contribute Materials

Your contribution can guide someone’s learning journey. Share your documents today.
Document Page
Home Page - Index.php
<?php
include_once('connect.php'); //include connection file
?>
<!DOCTYPE html>
<html>
<body>
<img src="logo.png " alt="logo" style="width:150px;height:150px;">
<head>
<link rel="stylesheet" type="text/css" href="css/style.css">
<meta charset="UTF-8">
<title>Poll voting</title>
<div class="h1">
<h1>Poll Here and Look at People Thoughts</h1>
</div>
<div class="h2">
<h2>Free Poll/Voting System that Is Available for Anyone</h2>
</div>
<!-- adding a clicable button for new page for voting-->
<a href="polling.php" class="button"> Create Your Polls Here</a>
</head>
<header>
<div class="header">
<nav class="navigation">

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
<div class="sign-up">
<?php if(isset($_SESSION['login'])) { ?>
<a href="logout.php">log out</a>
<?php } else { ?>
<a href="login.php">log in</a>
<a href="login.php">sign up</a>
<?php } ?>
</div>
<div class="navbar">
<a href="#">Home</a>
<a href="#">About</a>
<a href="#">Help</a>
<a href="#">Contact</a>
</div>
</nav>
<div class="video-container">
<video autoplay loop muted id="video-bg">
<source src="bg.mp4" type="video/mp4">
</video>
</div>
</div>
</body>
</header>
</html>
Document Page
Login/SignUp Page - login.php
<?php
include_once('connect.php'); //include connection file
if(isset($_POST['login'])) { //if user login
$uname = $_POST['username']; //get username from the form
$password = $_POST['password']; //get password from the form
$qryChkData = mysql_query("select * from users where username='".$uname."' and
user_password='".$password."'"); // query for check login //check for login
$rowNum = mysql_num_rows($qryChkData);
if($rowNum > 0) {
$_SESSION['login'] = "Success";
header('location:polling.php'); //go to polling page
}
else {
$_SESSION['msg'] = "E-Mail or Password Is not Correct"; //message for incorrect e-
mail or password
}
}
if(isset($_POST['signUp'])) { //if user click on signup
$uname = $_POST['username']; //get username
$email =$_POST['email']; //get email
$password = $_POST['password']; //get password
$qryInsertData = mysql_query("insert into users (username, user_email, user_password)
values ('".$uname."', '".$email."', '".$password."')"); // query to signup
Document Page
if($qryInsertData) {
$_SESSION['login'] = "Success";
header('location:polling.php');
}
else {
$_SESSION['msg'] = "Error In Sign Up"; //error message for invalid login
details
}
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Poll voting</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
<body>
<header class="header-basic">
<div class="header-limiter">
<h1 style="margin-left:180px;"><a href="#">Poll Here and
Look at People Thoughts</a></h1>
<nav>
<a href="index.php">Home</a>
<a href="polling.php">Polls</a>
<?php if(isset($_SESSION['login'])) { ?>
<a href="logout.php">Logout</a>
<?php } else { ?>
<a href="login.php">Log In</a>
<?php } ?>
</nav>
</div>
</header>
Document Page
<div style="width:60%; margin-left:200px; background-color:#3f3f6f; text-align:
center;">
<form action="" method="post">
<?php if(isset($_SESSION['msg'])) { ?><h1 style="color:white;"><?php echo
$_SESSION['msg']; unset($_SESSION['msg']); }?></h1>
<h1 style="color:white;"> Login Here:</h1>
<input type="text" name="username" placeholder="*Username" required><br><br>
<input type="password" name="password" placeholder="*Password"
required><br><br>
<input type="submit" name="login" value="Login" class="button"
style="width:8%;">
</form>
<form action="" method="post">
<h1 style="color:white;"> Sign Up Here:</h1>
<input type="text" name="username" placeholder="*Username" required><br><br>
<input type="text" name="email" placeholder="*E-Mail" required><br><br>
<input type="password" name="password" placeholder="*Password"
required><br><br>
<input type="submit" name="signUp" value="Sign Up" class="button"
style="width:9%;">
</form>
</div>
</body>
</html>
Document Page
Polls Page - polling.php
<?php
include_once('connect.php'); //include connection file
if(!isset($_SESSION['login'])) {
header('location:login.php');
}
if(isset($_POST['submit'])) {
$ques = $_POST['question'];
$ans1 =$_POST['ans1'];
$ans2 =$_POST['ans2'];
$ans3 =$_POST['ans3'];
$ans4 =$_POST['ans4'];
$qryInsertData = mysql_query("insert into questions (question, ans1, ans2, ans3, ans4) values
('".$ques."', '".$ans1."', '".$ans2."', '".$ans3."', '".$ans4."')"); //query to add question and
answers
header('location:questions.php'); // move to question page
}
?>
<!DOCTYPE html>
<html>
<head>

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
<title>Poll voting</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header class="header-basic">
<div class="header-limiter">
<h1 style="margin-left:180px;"><a href="#">Poll Here and
Look at People Thoughts</a></h1>
<nav>
<a href="index.php">Home</a>
<a href="polling.php">Polls</a>
<a href="logout.php">Logout</a>
</nav>
</div>
Document Page
</header>
<div style="width:60%; margin-left:200px; background-color:#3f3f6f; text-align:
center;">
<form action="" method="post">
<h1 style="color:white;"> Poll Question:</h1>
<textarea name="question" placeholder="Question?"></textarea>
<h1 style="color:white;"> Option Answers:</h1>
<input type="text" name="ans1" placeholder="*Option 1" required><br><br>
<input type="text" name="ans2" placeholder="*Option 2" required><br><br>
<input type="text" name="ans3" placeholder="*Option 3" required><br><br>
<input type="text" name="ans4" placeholder="*Option 4" required><br><br>
<input type="submit" name="submit" value="Submit" class="button" style="width:8%;">
</form>
</div>
</body>
</html>
Document Page
Question Page - question.php
<?php
include_once('connect.php');
$qryquestion = mysql_query("select * from questions"); // query to get all list of questions
?>
<!DOCTYPE html>
<html>
<head>
<title>Poll voting</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
</head>
<body>
<header class="header-basic">

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
<div class="header-limiter">
<h1 style="margin-left:180px;"><a href="#">Poll Here and
Look at People Thoughts</a></h1>
<nav>
<a href="index.php">Home</a>
<a href="polling.php">Polls</a>
<a href="logout.php">Logout</a>
</nav>
</div>
</header>
<div style="width:60%; margin-left:200px; background-color:#3f3f6f; text-align:
center;">
<h1 style="color:white;">Choose Any Question Below: </h1>
<?php while($sqlData = mysql_fetch_assoc($qryquestion)) { ?>
<h2><a href="answers.php?qid=<?php echo $sqlData['questions_id']; ?>" style="color:
#9a700a; text-decoration: none;">Q. <?php echo $sqlData['question']; ?>?</a></h2>
<?php } ?>
</div>
</body>
</html>
Document Page
Answer Page – answer.php
<?php
include_once('connect.php'); //include connection file
$ques_id = $_GET['qid']; //get question id
$qryAnswer = mysql_query("select * from questions where questions_id='".$ques_id."'"); //
query to get questions
$arrData = mysql_fetch_assoc($qryAnswer);
if(isset($_POST['submit'])) {
$ans = $_POST['ans'];
$qryInsertData = mysql_query("insert into polls (question_id, answer_id) values ('".
$ques_id."', '".$ans."')"); //query to insert data
header("Location:results.php?qid=".$ques_id);
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Poll voting</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
Document Page
</head>
<body>
<header class="header-basic">
<div class="header-limiter">
<h1 style="margin-left:180px;"><a href="#">Poll Here and
Look at People Thoughts</a></h1>
<nav>
<a href="index.php">Home</a>
<a href="polling.php">Polls</a>
<a href="logout.php">Logout</a>
</nav>
</div>
</header>
<div style="width:60%; margin-left:200px; background-color:#3f3f6f; text-align:
center;">
<form action="" method="post">
<h1 style="color:white;">Q. <?php echo $arrData['question']; ?></h1>

Secure Best Marks with AI Grader

Need help grading? Try our AI Grader for instant feedback on your assignments.
Document Page
<input type="radio" name="ans" value="1" checked><span style="color:white;"> <?php
echo $arrData['ans1']; ?></span><br>
<input type="radio" name="ans" value="m2ale" checked><span style="color:white;">
<?php echo $arrData['ans2']; ?></span><br>
<input type="radio" name="ans" value="3" checked><span style="color:white;"> <?php
echo $arrData['ans3']; ?></span><br>
<input type="radio" name="ans" value="4" checked><span style="color:white;"> <?php
echo $arrData['ans4']; ?></span><br><br>
<input type="submit" name="submit" value="Submit" class="button" style="width:9%;">
</form>
</div>
</body>
</html>
Document Page
Result Page – result.php
<?php
include_once('connect.php'); //include connection file
$ques_id = $_GET['qid'];
$qryOfAnswer = mysql_query("select * from questions where questions_id='".$ques_id."'");
$arrAnswer = mysql_fetch_assoc($qryOfAnswer); // get data of question
$qryChkAnswer1 = mysql_query("select * from polls where question_id='".$ques_id."' and
answer_id='1'");
$ans1 = mysql_num_rows($qryChkAnswer1); //get number of option with answer 1
$qryChkAnswer2 = mysql_query("select * from polls where question_id='".$ques_id."' and
answer_id='2'");
$ans2 = mysql_num_rows($qryChkAnswer2); //get number of option with answer 2
$qryChkAnswer3 = mysql_query("select * from polls where question_id='".$ques_id."' and
answer_id='3'");
$ans3 = mysql_num_rows($qryChkAnswer3); //get number of option with answer 3
$qryChkAnswer4 = mysql_query("select * from polls where question_id='".$ques_id."' and
answer_id='4'");
$ans4 = mysql_num_rows($qryChkAnswer4); //get number of option with answer 4
$qryAllQuestion = mysql_query("select * from questions");
while($sqlAllQuestion = mysql_fetch_assoc($qryAllQuestion)) {
$qryGetPoll = mysql_query("select * from polls where question_id='".
$sqlAllQuestion['questions_id']."'");
$totalPoll = mysql_num_rows($qryGetPoll);
$sqlAllQuestion['totalQues'] = $totalPoll; // get number of polls to each question
$arrQues[] = $sqlAllQuestion;
}
Document Page
?>
<!DOCTYPE html>
<html>
<head>
<title>Poll voting</title>
<link rel="stylesheet" type="text/css" href="css/style.css">
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>
</head>
<body>
<header class="header-basic">
<div class="header-limiter">
<h1 style="margin-left:180px;"><a href="#">Poll Here and
Look at People Thoughts</a></h1>

Paraphrase This Document

Need a fresh take? Get an instant paraphrase of this document with our AI Paraphraser
Document Page
<nav>
<a href="index.php">Home</a>
<a href="polling.php">Polls</a>
<a href="logout.php">Logout</a>
</nav>
</div>
</header>
<div id="myDiv" style="width: 80%; height: 500px; margin-left:100px;"></div>
<script>
var data = [{
x: ["<?php echo $arrAnswer['ans1']; ?>", "<?php echo $arrAnswer['ans2']; ?>", "<?php
echo $arrAnswer['ans3']; ?>", "<?php echo $arrAnswer['ans4']; ?>"],
y: ["<?php echo $ans1; ?>", "<?php echo $ans2; ?>", "<?php echo $ans3; ?>", "<?php
echo $ans4; ?>"],
type: 'bar'
}];
Plotly.newPlot('myDiv', data);
</script>
<div style="width:60%; margin-left:200px; background-color:#3f3f6f; text-align:
center;">
<h1 style="text-align:center;">Questions With Their Polls Count</h1>
<?php foreach($arrQues as $ques) { ?>
<h3 style="color:black;">Q. <?php echo $ques['question']; ?> ?</h3>
Document Page
<h4 style="color:black;">Total Polls :- <?php echo $ques['totalQues']; ?> </h4>
<?php } ?>
</div>
</body>
</html>
1 out of 18
[object Object]

Your All-in-One AI-Powered Toolkit for Academic Success.

Available 24*7 on WhatsApp / Email

[object Object]