Skip to content

Commit 01c1598

Browse files
author
SaFirefly
committed
Control switching between classes, level and specialty must match (issue #6)
1 parent 1e1c30b commit 01c1598

File tree

3 files changed

+28
-4
lines changed

3 files changed

+28
-4
lines changed

config.php

+8-2
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,17 @@
11
<?php
22

3-
$db = "cb";
4-
$connection = mysql_connect("host", "user", "password") or die("Database Connection Problem");
3+
$db = "yasser_permut_test";
4+
$host = "localhost";
5+
$user = "root";
6+
$pass = "mariadb";
7+
8+
$connection = mysql_connect($host, $user, $pass) or die("Database Connection Problem");
9+
510
// Test Connection
611
if (!$connection)
712
die("connection impossible");
813
// DB Connection
914
mysql_select_db($db) or die("Connection Problem");
15+
1016
?>
1117

functions.php

+19
Original file line numberDiff line numberDiff line change
@@ -55,4 +55,23 @@ function get_gravatar( $email, $s = 80, $d = 'mm', $r = 'g', $img = false, $atts
5555
return $url;
5656
}
5757

58+
function check_class_correspondency($from, $to){
59+
60+
$from_numbers = array();
61+
preg_match_all('/([0-9]+)/', $from, $from_numbers);
62+
$from_level = $from_numbers[0][0];
63+
$from_groupe = $from_numbers[0][1];
64+
$from_specialty = array();
65+
preg_match('/([A-Z]+)/', $from, $from_specialty);
66+
67+
$to_numbers = array();
68+
preg_match_all('/([0-9]+)/', $to, $to_numbers);
69+
$to_level = $to_numbers[0][0];
70+
$to_groupe = $to_numbers[0][1];
71+
$to_specialty = array();
72+
preg_match('/([A-Z]+)/', $to, $to_specialty);
73+
74+
return (($from_level == $to_level) && ($from_specialty[0] == $to_specialty[0]) && ($from_groupe != $to_groupe));
75+
}
76+
5877
?>

inscri.php

+1-2
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,7 @@
1414

1515

1616

17-
if (($nom!="") &&($prenom!="")&&($from!="")&&($to!="") && ($cin!="") && ($contact!="")&& (strlen($cin)==8 ) && (is_numeric($cin)) )
18-
{
17+
if (($nom!="") &&($prenom!="")&&($from!="")&&($to!="") && ($cin!="") && ($contact!="")&& (strlen($cin)==8 ) && (is_numeric($cin)) && check_class_correspondency($from, $to)){
1918

2019

2120
if ($act==1) {include_once("filtre.php"); exit;}

0 commit comments

Comments
 (0)