Bonjour à tous
j'ai cette fonction js qui me gère les validateurs:
Code : Sélectionner tout - Visualiser dans une fenêtre à part
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 var FormValidation11 = function () { var handleValidation1 = function() { // for more info visit the official plugin documentation: // http://docs.jquery.com/Plugins/Validation var form1 = $('#form_sample_01'); var error1 = $('.alert-error', form1); var success1 = $('.alert-success', form1); form1.validate({ errorElement: 'span', //default input error message container errorClass: 'help-inline', // default input error message class focusInvalid: false, // do not focus the last invalid input ignore: "", rules: { username: { required: true, }, password: { required: true, }, }, messages:{ username: { required: 'Nom d\'utilisateur obligatoire', }, password: { required: 'Mot de passe obligatoire', }, }, invalidHandler: function (event, validator) { //display error alert on form submit success1.hide(); error1.show(); FormValidation11.scrollTo(error1, -200); }, highlight: function (element) { // hightlight error inputs $(element) .closest('.help-inline').removeClass('ok'); // display OK icon $(element) .closest('.control-group').removeClass('success').addClass('error'); // set error class to the control group }, unhighlight: function (element) { // revert the change done by hightlight $(element) .closest('.control-group').removeClass('error'); // set error class to the control group }, success: function (label) { label .addClass('valid').addClass('help-inline ok') // mark the current input as valid and display OK icon .closest('.control-group').removeClass('error').addClass('success'); // set success class to the control group }, submitHandler: function (form) { success1.show(); error1.hide(); } }); } return { //main function to initiate the module init: function () { handleValidation1(); }, // wrapper function to scroll to an element scrollTo: function (el, offeset) { pos = el ? el.offset().top : 0; jQuery('html,body').animate({ scrollTop: pos + (offeset ? offeset : 0) }, 'slow'); } }; }();
et voici ma page php
Code html : Sélectionner tout - Visualiser dans une fenêtre à part
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 <!DOCTYPE html> <html lang="fr"> <head> <!-- start: Meta --> <meta charset="utf-8"> <meta name="description" content="Bootstrap Metro Dashboard"> <meta name="author" content="Dennis Ji"> <meta name="viewport" content="width=device-width, initial-scale=1"> <link href="assets/styles.css" rel="stylesheet" media="screen"> <link id="bootstrap-style" href="css/bootstrap.min.css" rel="stylesheet"> <link href="css/bootstrap-responsive.min.css" rel="stylesheet"> <link id="base-style" href="css/style_login.css" rel="stylesheet"> <link id="base-style-responsive" href="css/style-responsive.css" rel="stylesheet"> <link href='http://fonts.googleapis.com/css?family=Open+Sans:300italic,400italic,600italic,700italic,800italic,400,300,600,700,800&subset=latin,cyrillic-ext,latin-ext' rel='stylesheet' type='text/css'> <link rel="shortcut icon" href="img/favicon.ico"> <script src="vendors/modernizr-2.6.2-respond-1.1.0.min.js"></script> </head> <body> <div id="header-login"> </div> <div id="title-login"> </div> <div style="max-width:100%;"> <div style="float:left;width:500px; "> <img class="img-login" src="img/logo-at.jpg" /> </div> <div style="margin-left:450px;"> <div id="login"> <h1><strong>Authentification</strong></h1> <form class="form-horizontal" action="" method="post" id="form_sample_01"> <fieldset > <div class="alert alert-error hide erreur_box"> <button class="close" data-dismiss="alert"></button>"<?=$message?>" </div> <div class="control-group " > <input id="username" type="text" name="username" class="input-xlarge focused span6 m-wrap i" style=" width:96%; margin-left:0px;"> <div style="padding-top:20px;heigh:10px;"></div> <input id="password" type="password" name="password" class="input-xlarge focused span6 m-wrap i" style=" width:96%; margin-left:0px;"> </div> <div style="padding-top:20px;heigh:10px;"></div> <input type="submit" name="connexion" value="Connexion" /> </fieldset> </form> </div> </div> </div> <!-- start: contenu page --> <!-- end: contenu page --> <!-- start: JavaScript--> <script src="js/jquery-1.9.1.min.js"></script> <script src="js/jquery-migrate-1.0.0.min.js"></script> <script src="js/jquery-ui-1.10.0.custom.min.js"></script> <script src="js/jquery.ui.touch-punch.js"></script> <script src="js/modernizr.js"></script> <script src="js/bootstrap.min.js"></script> <script src="js/bootstrap.js"></script> <script src="js/jquery.cookie.js"></script> <script src='js/fullcalendar.min.js'></script> <script src='js/jquery.dataTables.min.js'></script> <script src="js/excanvas.js"></script> <script src="js/jquery.flot.js"></script> <script src="js/jquery.flot.pie.js"></script> <script src="js/jquery.flot.stack.js"></script> <script src="js/jquery.flot.resize.min.js"></script> <script src="js/jquery.chosen.min.js"></script> <script src="js/jquery.uniform.min.js"></script> <script src="js/jquery.cleditor.min.js"></script> <script src="js/jquery.noty.js"></script> <script src="js/jquery.elfinder.min.js"></script> <script src="js/jquery.raty.min.js"></script> <script src="js/jquery.iphone.toggle.js"></script> <script src="js/jquery.uploadify-3.1.min.js"></script> <script src="js/jquery.gritter.min.js"></script> <script src="js/jquery.imagesloaded.js"></script> <script src="js/jquery.masonry.min.js"></script> <script src="js/jquery.knob.modified.js"></script> <script src="js/jquery.sparkline.min.js"></script> <script src="js/counter.js"></script> <script src="js/retina.js"></script> <script src="js/custom.js"></script> <script src="js/show_hide.js"></script> <link href="vendors/datepicker.css" rel="stylesheet" media="screen"> <link href="vendors/uniform.default.css" rel="stylesheet" media="screen"> <link href="vendors/chosen.min.css" rel="stylesheet" media="screen"> <link href="vendors/wysiwyg/bootstrap-wysihtml5.css" rel="stylesheet" media="screen"> <script src="vendors/jquery-1.9.1.js"></script> <script src="bootstrap/js/bootstrap.min.js"></script> <script src="vendors/jquery.uniform.min.js"></script> <script src="vendors/chosen.jquery.min.js"></script> <script src="vendors/bootstrap-datepicker.js"></script> <script src="vendors/wysiwyg/wysihtml5-0.3.0.js"></script> <script src="vendors/wysiwyg/bootstrap-wysihtml5.js"></script> <script src="vendors/wizard/jquery.bootstrap.wizard.min.js"></script> <script type="text/javascript" src="vendors/jquery-validation/dist/jquery.validate.min.js"></script> <script src="assets/form-validation.js"></script> <script src="assets/scripts.js"></script> <script> jQuery(document).ready(function() { FormValidation11.init(); }); $(function() { $(".datepicker").datepicker(); $(".uniform_on").uniform(); $(".chzn-select").chosen(); $('.textarea').wysihtml5(); $('#rootwizard').bootstrapWizard({onTabShow: function(tab, navigation, index) { var $total = navigation.find('li').length; var $current = index+1; var $percent = ($current/$total) * 100; $('#rootwizard').find('.bar').css({width:$percent+'%'}); // If it's the last tab then hide the last button and show the finish instead if($current >= $total) { $('#rootwizard').find('.pager .next').hide(); $('#rootwizard').find('.pager .finish').show(); $('#rootwizard').find('.pager .finish').removeClass('disabled'); } else { $('#rootwizard').find('.pager .next').show(); $('#rootwizard').find('.pager .finish').hide(); } }}); $('#rootwizard .finish').click(function() { alert('Finished!, Starting over!'); $('#rootwizard').find("a[href*='tab1']").trigger('click'); }); }); </script> <!-- end: JavaScript--> </body> </html> <?php error_reporting(0); session_destroy(); session_start(); include("connexion.php"); echo '0'; $message='Veuillez insérer nom dutilisateur et mot de passe'; if (isset($_POST['connexion'])) { echo '3'; $username = $_POST['username']; $password = $_POST['password']; $sql_stmt= "SELECT username,password FROM admin_sup WHERE username='".$username."'"; $result = mysql_query($sql_stmt) or die ("Erreur de requête sur la table de base de données"); $rs_array=mysql_fetch_assoc($sql_stmt); echo '1'; if($rs_array['username']) { if($rs_array['password']==$password) { $_SESSION['username']=$username; } else { $message="Mot de passe saisi est incorrect"; } } else { $message ="Nom dutilisateur saisi est incorrect"; echo '2'; } } else { echo '4'; } ?>
mon problème est quant je mets le if de ma form la fonction Get ne récupère rien
et quand je la supprime la fonction GET me retourne un résultat
Partager