-
Notifications
You must be signed in to change notification settings - Fork 1
/
update.php
executable file
·208 lines (180 loc) · 9.98 KB
/
update.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
<!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">
<meta name="description" content="">
<meta name="author" content="">
<link rel="icon" href="../../favicon.ico">
<title>APP ON THE FLY</title>
<!-- Bootstrap core CSS -->
<link href="css/bootstrap.min.css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="css/jumbotron.css" rel="stylesheet">
<!-- Just for debugging purposes. Don't actually copy these 2 lines! -->
<!--[if lt IE 9]>
<script src="../../assets/js/ie8-responsive-file-warning.js"></script><![endif]-->
<script src="js/ie-emulation-modes-warning.js"></script>
<script type="text/javascript" src="js/jquery.min.js"></script>
<!-- script to add textboxes dynamically-->
<script type="text/javascript" src="js/text.js"></script>
<!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
<!--[if lt IE 9]>
<script src="https://oss.maxcdn.com/html5shiv/3.7.2/html5shiv.min.js"></script>
<script src="https://oss.maxcdn.com/respond/1.4.2/respond.min.js"></script>
<![endif]-->
</head>
<body>
<?php include 'headerlogin.php'; ?>
<div class="container marketing" id="container">
<div class="row row-offcanvas row-offcanvas-right">
<div class="col-xs-12">
<div class="row">
<div class="col-xs-4 myframe">
<h2>Enter all the details</h2>
<hr class="featurette-divider-small">
<form role="form" action="update.php" method="post">
<div class="form-group">
<label for="host">Host / IP:</label>
<input type="text" class="form-control" name="host" placeholder="host/ip for database"
required/>
</div>
<div class="form-group">
<label for="user">User name:</label>
<input type="text" class="form-control" name="user" placeholder="username for database"
required/>
</div>
<div class="form-group">
<label for="password">Password:</label>
<input type="password" class="form-control" name="pwd" placeholder="password for database"
required/>
</div>
<div class="form-group">
<label for="user">Database Name:</label>
<input type="text" class="form-control" name="db" placeholder="database name" required/>
</div>
<div class="form-group">
<label for="user">Table Name:</label>
<input type="text" class="form-control" name="table" placeholder="table name" required/>
</div>
<div class="form-group">
<label for="field1">Field1 Name:</label>
<input type="text" class="form-control" name="textbox[1]" placeholder="field1 name"/>
</div>
<div class="form-group">
<label for="field2">Field2 Name:</label>
<input type="text" class="form-control" name="textbox[2]" placeholder="field2 name"/>
</div>
<div class="form-group">
<input type="hidden" name="count" id="hidden" class="form-control" name="count"/>
</div>
<hr>
<div id='TextBoxesGroup'>
<div id="TextBoxDiv1" class="form-group">
<!--<label>Field3 name : </label>
<input type='text' id='textbox3' name='textbox3' class="form-control" placeholder="field3 name">-->
</div>
</div>
<input type='button' value='Add New Field' id='addButton' class="btn btn-default">
<input type='button' value='Remove Last Field' id='removeButton' class="btn btn-default">
<!--<input type='button' value='Get Value' id='getButtonValue' class="btn btn-default">-->
<hr>
<input type="submit" value="Generate" name="Generate" class="btn btn-info"/>
</form>
</div>
<div class="col-xs-7 myframe">
<h2>Generated code for updation</h2>
<hr class="featurette-divider-small">
<?php
if (isset($_POST['Generate'])) {
$i = 0;
$sp = 6;
$host = $_POST['host'];
$user = $_POST['user'];
$pwd = $_POST['pwd'];
$db = $_POST['db'];
$count = $_POST['count'];
foreach($_POST['textbox'] as $index=>$checkbox) {
$field[$index]=$checkbox;
//echo $field[$index];
}
$table = $_POST['table'];
$msg = '<!doctype html> <br/>';
$msg .= '<html lang="en"> <br/>';
$msg .= str_repeat(" ", $sp * ++$i);
$msg .= '<head> <br/>';
$msg .= str_repeat(" ", $sp * ++$i);
$msg .= '<meta charset="utf-8"> <br/>';
$msg .= str_repeat(" ", $sp * $i);
$msg .= '<meta name="viewport" content="width=device-width; initial-scale=1.0"> <br/>';
$msg .= str_repeat(" ", $sp * $i);
$msg .= '<title> example </title> <br/>';
$msg .= str_repeat(" ", $sp * --$i);
$msg .= '</head> <br/><br/>';
$msg .= str_repeat(" ", $sp * $i);
$msg .= '<body> <br/>';
$msg .= str_repeat(" ", $sp * ++$i);
$msg .= '<form action=' . "<?php echo \$_SERVER['PHP_SELF'];?>" . " method=\"post" . "\"/>" . "<br/>";
$msg .= str_repeat(" ", $sp * ++$i);
$str="";
$commacount=1;
foreach($_POST['textbox'] as $index=>$checkbox) {
$msg .= '<label>' . $field[$index] . '</label>';
$msg .= '<input type="text" name="' . $field[$index] . '"/>' . "<br/>";
$msg .= str_repeat(" ", $sp * $i);
$str .= "\"\$$field[$index]\"";
if($commacount++!=$count)
$str .=",";
}
$msg .= str_repeat(" ", $sp * $i);
$msg .= '<input type="submit" value="submit"/>' . '<br/>';
$msg .= str_repeat(" ", $sp * --$i);
$msg .= '</form>' . '<br/>';
$msg .= str_repeat(" ", $sp * --$i);
$msg .= '</body>' . '<br/><br/>';
$msg .= str_repeat(" ", $sp * $i);
$msg .= '<?php' . '<br/>';
$msg .= str_repeat(" ", $sp * ++$i);
$msg .= "if(\$_POST) {" . "<br/>";
$msg .= str_repeat(" ", $sp * ++$i);
$msg .= "\$con=\"mysqli_connect(\"$host\",\"$user\",\"$pwd\",\"$db\")\"" . ";" . "<br/>";
$msg .= str_repeat(" ", $sp * $i);
$msg .= "if(\$con) {" . "<br/>";
$msg .= str_repeat(" ", $sp * ++$i);
$msg .= "\$sql=\"insert into $table values($str" . ");" . "<br/>";
$msg .= str_repeat(" ", $sp * $i);
$msg .= "if(res=mysqli_query(\"\$con\",\"\$sql\")) {" . "<br/>";
$msg .= str_repeat(" ", $sp * $i);
$msg .= 'echo "inserted successfully"' . ';' . '<br/>';
$msg .= str_repeat(" ", $sp * --$i);
$msg .= '}' . '<br/>';
$msg .= str_repeat(" ", $sp * $i);
$msg .= 'else {' . '<br/>';
$msg .= str_repeat(" ", $sp * ++$i);
$msg .= 'echo "insertion failed"' . ';' . '<br/>';
$msg .= str_repeat(" ", $sp * --$i);
$msg .= '}' . '<br/>';
$msg .= str_repeat(" ", $sp * --$i);
$msg .= '}' . '<br/>';
$msg .= str_repeat(" ", $sp * --$i);
$msg .= "?>" . "<br/><br/>";
$msg .= '</html>' . '<br/>';
echo $msg;
}
?>
</div>
</div>
</div>
</div>
</div>
</div>
<?php include 'footer.php'; ?>
<!-- Bootstrap core JavaScript
================================================== -->
<!-- Placed at the end of the document so the pages load faster -->
<script src="js/bootstrap.min.js"></script>
<!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
<script src="js/ie10-viewport-bug-workaround.js"></script>
</body>
</html>