-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathtest.php
87 lines (87 loc) · 1.97 KB
/
test.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
78
79
80
81
82
83
84
85
86
87
<?php
if($_SERVER["REQUEST_METHOD"]=="POST")
{
$id=$_POST['id'];
$cols=$_POST['number'];
$i=0;
echo "<form method=\"get\" action=\"test.php\">";
for($i=0;$i<$cols;$i++)
{
$name="test_".$i;
echo "Name of test no.$i";
echo "<input type=\"text\" name=\"$name\"></input><br>";
}
echo "<input type=\"hidden\" name=\"col\" value=\"$cols\"></input>";
echo "<input type=\"hidden\" name=\"id\" value=\"$id\"></input>";
echo "<input type=\"submit\"></input>";
echo "</form>";
}
if($_SERVER["REQUEST_METHOD"]=="GET")
{
$c=$_GET['col'];
$id=$_GET['id'];
for($i=0;$i<$c;$i++)
{
$name="test_".$i;
$name=$_GET[$name];
echo $name."<br>";
}
$conn =new mysqli("localhost","root","","tests");
$sql="CREATE TABLE test_for";
$sql.=$id;
$sql.="(username VARCHAR(30)";
for($i=0;$i<$c;$i++)
{
$name="test_".$i;
$name=$_GET[$name];
$sql.=",";
$sql.=$name;
$sql.=" INT(10) DEFAULT '0'";
}
$sql.=")";
if($conn->query($sql)===TRUE)
{
echo "test generated";
}
else
{
echo $conn->error;
}
$sql="CREATE TABLE template_for$id(column_name VARCHAR(30))";
$conn->query($sql);
$sql="INSERT INTO template_for$id(column_name) VALUES('username')";
$conn->query($sql);
for($i=0;$i<$c;$i++)
{
$name="test_".$i;
$name=$_GET[$name];
$sql="INSERT INTO template_for$id(column_name) VALUES('$name')";
if($conn->query($sql)===TRUE)
{
echo "success";
}
else
{
echo $conn->error;
}
}
$conn1 =new mysqli("localhost","root","","online_recruitment");
$sql="SELECT username FROM applies_for WHERE notification_id='$id'";
$result=$conn1->query($sql);
while($row=$result->fetch_assoc())
{
$name=$row['username'];
$sql="INSERT INTO test_for$id(username) VALUES('$name')";
if($conn->query($sql))
{
echo "lala";
}
else
{
echo $conn->error;
}
}
$conn1->close();
$conn->close();
}
?>