forked from milindkesar/webappmenti
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathformsub.php
69 lines (56 loc) · 1.54 KB
/
formsub.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
<!DOCTYPE html>
<html>
<?php
print_r($_POST);
echo "<br>";
echo $_POST["question0"];
$count=0;
$count1=0;
$string='';
$var1='sec'.$count.'option'.$count1;
$var='question'.$count;
$var2='choice'.$count;
$flag=0;
$six_digit_random_number = mt_rand(100000, 999999);
$check="SELECT * FROM table where uniqueid='$six_digit_random_number'";
$conn=new mysqli("localhost","root","","menti");
if($conn->connect_error){
die("Connection failed: ".$conn->connect_error);
}
$rs=mysqli_query($conn,$check);
while($flag==0){
$data=mysqli_fetch_array($rs,MYSQLI_NUM);
if($data[0] > 1){
$six_digit_random_number = mt_rand(100000, 999999);
}
else{
$flag=1;
}
}
while(isset($_POST[$var]))
{
while(isset($_POST[$var1]))
{
$string=$string.','.$_POST[$var1];
$count1=$count1+1;
$var1='sec'.$count.'option'.$count1;
}
$string=substr($string,1);
$sql="INSERT INTO table1 (question,options,choice,uniqueid) VALUES ('$_POST[$var]','$string','$_POST[$var2]','$six_digit_random_number')";
if($conn->query($sql)===TRUE){
echo "New record created successfully";
}
else{
echo "Error: ".$sql."<br>".$conn->error;
}
$count=$count+1;
$var='question'.$count;
$var2='choice'.$count;
$count1=0;
$var1='sec'.$count.'option0';
$string='';
}
$conn->close();
echo "Your id is".$six_digit_random_number."!";
?>
</html>