-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathq_admin.php
58 lines (55 loc) · 1.88 KB
/
q_admin.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
<?php
if($_SERVER["REQUEST_METHOD"] == "GET")
{
$question = $_GET['question'];
$opta = $_GET['opta'];
$optb = $_GET['optb'];
$optc = $_GET['optc'];
$optd = $_GET['optd'];
$answer = $_GET['answer'];
$type = $_GET['type'];
if (!empty($question) && !empty($opta) && !empty($optb) && !empty($optc) && !empty($optd) && !empty($answer) && !empty($type)) {
$host = "localhost";
$dbUsername = "root";
$dbPassword = "";
$dbname = "english";
//create connection
$conn = new mysqli($host, $dbUsername, $dbPassword, $dbname);
//to prevent mysql injection
//For prevention against data stealing
$question=stripcslashes($question);
$opta=stripcslashes($opta);
$optb=stripcslashes($optb);
$optc=stripcslashes($optc);
$optd=stripcslashes($optd);
$answer=stripcslashes($answer);
$type=stripcslashes($type);
$question=mysqli_real_escape_string($conn,$question);
$opta=mysqli_real_escape_string($conn,$opta);
$optb=mysqli_real_escape_string($conn,$optb);
$optc=mysqli_real_escape_string($conn,$optc);
$optd=mysqli_real_escape_string($conn,$optd);
$answer=mysqli_real_escape_string($conn,$answer);
$type=mysqli_real_escape_string($conn,$type);
if (mysqli_connect_error()) {
die('Connect Error('. mysqli_connect_errno().')'. mysqli_connect_error());
} else
{
$query = "INSERT Into q_admin (id,question,opta,optb,optc,optd,answer,type) values('$id','$question','$opta','$optb','$optc','$optd','$answer','$type')";
$res=mysqli_query($conn,$query);
if($res)
{
echo "Question successfully uploaded.";
}
else
{
echo "Upload Error";
echo mysqli_error($conn);
}
}
} else {
echo "All field are required";
die();
}
}
?>