-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcreate_table.php
More file actions
72 lines (71 loc) · 1.57 KB
/
create_table.php
File metadata and controls
72 lines (71 loc) · 1.57 KB
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
<?php
$choices='';
session_start();
if(isset($_POST['go']))
{
$n=$_POST['number'];
for($i=0;$i<$n;$i++)
{
$choices.=($i+1).". <input type='text' name='c".$i."' required><br>";
}
$choices.="<input type='submit' name='submit' value='create' id='submit'>";
$_SESSION['number']=$n;
}
if(isset($_POST['submit']))
{
$x=$_SESSION['user'];
$conn = mysqli_connect('localhost','root','Aa#123','datastorage');
mysqli_query($conn,"CREATE TABLE userp".$x." (id INT AUTO_INCREMENT PRIMARY KEY)");
for($i=0;$i<$_SESSION['number'];$i++)
{
$a=$_POST["c".$i];
mysqli_query($conn,"ALTER TABLE userp".$x." ADD $a varchar(255);");
}
mysqli_query($conn,"UPDATE users SET table_flag=1 WHERE id=$x");
header('Location: main.php');
}
?>
<!DOCTYPE html>
<html>
<head>
<title>Create Table</title>
<style>
body
{
background-color:grey;
padding : 0px 0px 150px 0px;
}
form
{
background-color:white;
width:20%;
padding : 10px 20px 10px 20px;
font-size:25px;
}
label
{
font-size:30px;
}
input
{
font-size : 20px;
}
#submit
{
background-color:lightgreen;
width:100%;
}
</style>
</head>
<body>
<center>
<h1>Step 1 : Create Table</h1>
<form method="POST" action="<?php echo $_SERVER['PHP_SELF']; ?>">
<label>Number of columns :</label>
<input type="text" name="number" value="<?php if(isset($_POST['go'])) echo $_POST['number']; else echo '4'; ?>">
<input type="submit" name="go" value="Go" id="submit"><br>
<?php echo $choices; ?>
</form>
</center>
</body>
</html>