-
Notifications
You must be signed in to change notification settings - Fork 0
/
newpoll.php
77 lines (68 loc) · 2.76 KB
/
newpoll.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
<?php
session_start();
$server="localhost";
$username="root";
$password="";
$database="delta_task3";
$con=mysqli_connect($server,$username,$password,$database);
$userid=$_SESSION['adminid'];
$details="SELECT * FROM `delta_task3`.`details` where `Username`='$userid'";
$check = mysqli_query($con, $details);
$myDetail = mysqli_fetch_array($check);
if(isset($_POST['option1'])&&isset($_POST['option2'])&&isset($_POST['option3'])&&isset($_POST['option4'])){
$question=$_POST["question"];
$option1= $_POST["option1"];
$option2= $_POST["option2"];
$option3= $_POST["option3"];
$option4= $_POST["option4"];
$sql = "INSERT INTO `delta_task3`.`trial` (`Username`,`Question`,`option1`, `option2`, `option3`, `option4`,`timestamp`) VALUES ('$userid','$question','$option1','$option2','$option3','$option4',current_timestamp())";
if($con->query($sql)==true){
echo '<script>
alert("Poll has been generated")
</script>';
$create="create TABLE `".$question."` (Name varchar(255) not null,Username varchar(255) not null,Email varchar(255) not null)";
$result=mysqli_query($con,$create);
}
$con->close();
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<link rel="stylesheet" href="newpoll.css">
<link href="https://fonts.googleapis.com/css2?family=Dancing+Script:wght@700&display=swap" rel="stylesheet">
<title>New Poll</title>
</head>
<body text="white">
<div class="nav">
<button id="back" onclick="location.href='dashboard_admin.php'">BACK</button>
<button id="logout" onclick="location.href='logout.php'">LOGOUT</button>
</div>
<div class="main">
<?php
echo "<div class=details>
<h5>NAME: $myDetail[Name]</h5><br>
<h5>USERNAME: $myDetail[Username]</h5><br>
<h5>EMAIL: $myDetail[Email]</h5><br></div> ";
?>
<div class="container" >
<h1>Create a new poll</h1>
<form action="newpoll.php" method="POST">
<input name='question' type='text' placeholder="Write your question here" id="question">
<input name="option1" type="text" placeholder="Option1" id="option1">
<input name="option2" type="text" placeholder="Option2" id="option2">
<input name="option3" type="text" placeholder="Option3" id="option3">
<input name="option4" type="text" placeholder="Option4" id="option4">
<input type="submit" id="btn">
</form>
</div>
<img id="img" src="deltaLogoGreen.png">
</div>
<div class="bottom">
<p style="margin:top 10px;">Made with ❤ by Raghav</p>
</div>
</body>
</html>