-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathindex2.php
88 lines (79 loc) · 2.58 KB
/
index2.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
<?php session_start(); ?>
<!DOCTYPE html>
<html>
<head>
<title>SELECT STUDENTS</title>
<script type="text/javascript" src="jquery-latest.js"></script>
<style type="text/css">
<!--
#main {
max-width: 800px;
margin: 0 auto;
}
-->
</style>
</head>
<body>
<div id="main">
<h1>SELECT STUDENTS</h1>
<div class="my-form">
<center>
<form role="form" method="post">
<fieldset>
<legend> STUDENTS </legend>
<p class="text-box">
<label for="box1">ROLLNO <span class="box-number">1</span></label>
<input type="text" name="boxes[]" value="" id="box1" />
<a class="add-box" href="#">Add + </a>
</p>
<p><input type="submit" value="Submit" /></p>
</fieldset>
</form>
</center>
</div>
</div>
<script type="text/javascript">
jQuery(document).ready(function($){
$('.my-form .add-box').click(function(){
var n = $('.text-box').length + 1;
if( 15 < n ) {
alert('Stop it!');
return false;
}
var box_html = $('<p class="text-box"><label for="box' + n + '">ROLLNO <span class="box-number">' + n + '</span></label> <input type="text" name="boxes[]" value="" id="box' + n + '" /> <a href="#" class="remove-box">Remove</a></p>');
box_html.hide();
$('.my-form p.text-box:last').after(box_html);
box_html.fadeIn('slow');
return false;
});
$('.my-form').on('click', '.remove-box', function(){
$(this).parent().css( 'background-color', '#FF6C6C' );
$(this).parent().fadeOut("slow", function() {
$(this).remove();
$('.box-number').each(function(index){
$(this).text( index + 1 );
});
});
return false;
});
});
</script>
<?php
if ($_SERVER["REQUEST_METHOD"] == "POST"){
$con = new mysqli ("localhost", "root", "time.org", "seproject");
if ($con->connect_error){
die("Cannot connect: " .$con->connect_error);
}
$work = $_SESSION['WorkID'];
//echo $name;
//please assume boxes = training
foreach($_POST['boxes'] as $textbox){
$training= $textbox;
//echo $training;
$AddQuery ="INSERT INTO PrivateWork (RollNo, WorkID) VALUES ('$training', '$work')";
$con->query($AddQuery);
}
}
?>
</body>
</html>