appel d'une fonction avec PHP
jai un probleme avec l'appel de ma fonction PHP. jai 4 fonctions a apppelee, je voulais verifier que si:
Code:
1 2 3 4 5
| if(getNumCamtel() && getNumMtn()){
}elseif(getNumMtn() && getNumOrange()){
}.... |
// voici lers codes
Code:
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
| <?php
function getNumCamtel(){
$GLOBALS['camtel'] = $GLOBALS['num_camtel'];
if(!empty($GLOBALS['camtel'])){
if(is_numeric($GLOBALS['camtel'])){
if($GLOBALS['camtel'] > 0){
if(strlen($GLOBALS['camtel']) == 9){
$GLOBALS['camtel_en_tab'] = str_split($GLOBALS['camtel'], 1);
if(($GLOBALS['camtel_en_tab'][0] == 2 && $GLOBALS['camtel_en_tab'][1] == 2) || ($GLOBALS['camtel_en_tab'][0] == 2 && $GLOBALS['camtel_en_tab'][1] == 3) || ($GLOBALS['camtel_en_tab'][0] == 2 && $GLOBALS['camtel_en_tab'][1] == 4)){
$GLOBALS['camtel_valide'] = $GLOBALS['camtel'];
return $GLOBALS['camtel_valide'];
}else{
header("Location:../index.php?erreur=Le numéro CAMTEL est incorrect");
}
}else{
header("Location:../index.php?erreur=Le numéro CAMTEL doit contenir exactement 09 caracteres");
}
}else{
header("Location:../index.php?erreur=Votre numéro CAMTEL doit pas contenir un signe negatif");
}
}else{
header("Location:../index.php?erreur=Le numéro CAMTEL doit etre un entier");
}
}
}
?> |
// 2e fonction
Code:
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
| <?php
function getNumMtn(){
$GLOBALS['mtn'] = $GLOBALS['num_mtn'];
if(!empty($GLOBALS['mtn'])){
if(is_numeric($GLOBALS['mtn'])){
if($GLOBALS['mtn'] > 0){
if(strlen($GLOBALS['mtn']) == 9){
$GLOBALS['mtn_en_tab'] = str_split($GLOBALS['mtn'], 1);
if(($GLOBALS['mtn_en_tab'][0] == 6 && $GLOBALS['mtn_en_tab'][1] == 5 && $GLOBALS['mtn_en_tab'][2] <= 4)|| ($GLOBALS['mtn_en_tab'][0] == 6 && $GLOBALS['mtn_en_tab'][1] == 7) || ($GLOBALS['mtn_en_tab'][0] == 6 && $GLOBALS['mtn_en_tab'][1] == 8) && ($GLOBALS['mtn_en_tab'][0] == 6 && $GLOBALS['mtn_en_tab'][2] <= 4)){
$GLOBALS['mtn_valide'] = $GLOBALS['mtn'];
return $GLOBALS['mtn_valide'];
}else{
header("Location:../index.php?erreur=Le numéro MTN est incorrect");
}
}else{
header("Location:../index.php?erreur=Le numéro MTN doit contenir exactement 09 caracteres");
}
}else{
header("Location:../index.php?erreur=Votre numéro MTN doit pas contenir un signe negatif");
}
}else{
header("Location:../index.php?erreur=Le numéro MTN doit etre un entier");
}
}
}
?> |
//3e fonction
Code:
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
| <?php
function getNumNexttel(){
$GLOBALS['nexttel'] = $GLOBALS['num_nexttel'];
if(!empty($GLOBALS['nexttel'])){
if(is_numeric($GLOBALS['nexttel'])){
if($GLOBALS['nexttel'] > 0){
if(strlen($GLOBALS['nexttel']) == 9){
$GLOBALS['nexttel_en_tab'] = str_split($GLOBALS['nexttel'], 1);
if(($GLOBALS['nexttel_en_tab'][0] == 6 && $GLOBALS['nexttel_en_tab'][1] == 8 && $GLOBALS['nexttel_en_tab'][2] == 5)|| ($GLOBALS['nexttel_en_tab'][0] == 6 && $GLOBALS['nexttel_en_tab'][1] == 6)){
$GLOBALS['nexttel_valide'] = $GLOBALS['nexttel'];
return $GLOBALS['nexttel_valide'];
}else{
header("Location:../index.php?erreur=Le numéro nexttel est incorrect");
}
}else{
header("Location:../index.php?erreur=Le numéro nexttel doit contenir exactement 09 caracteres");
}
}else{
header("Location:../index.php?erreur=Votre numéro nexttel doit pas contenir un signe negatif");
}
}else{
header("Location:../index.php?erreur=Le numéro nexttel doit etre un entier");
}
}
}
?> |
//4em fct
Code:
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
| <?php
function getNumOrange(){
$GLOBALS['orange'] = $GLOBALS['num_orange'];
if(!empty($GLOBALS['orange'])){
if(is_numeric($GLOBALS['orange'])){
if($GLOBALS['orange'] > 0){
if(strlen($GLOBALS['orange']) == 9){
$GLOBALS['orange_en_tab'] = str_split($GLOBALS['orange'], 1);
if(($GLOBALS['orange_en_tab'][0] == 6 && $GLOBALS['orange_en_tab'][1] == 5 && ($GLOBALS['orange_en_tab'][2] >= 5 && $GLOBALS['orange_en_tab'][2] <= 7))|| ($GLOBALS['orange_en_tab'][0] == 6 && $GLOBALS['orange_en_tab'][1] == 9)){
$GLOBALS['orange_valide'] = $GLOBALS['orange'];
return $GLOBALS['orange_valide'];
}else{
header("Location:../index.php?erreur=Le numéro Orange est incorrect");
}
}else{
header("Location:../index.php?erreur=Le numéro Orange doit contenir exactement 09 caracteres");
}
}else{
header("Location:../index.php?erreur=Votre numéro Orange doit pas contenir un signe negatif");
}
}else{
header("Location:../index.php?erreur=Le numéro Orange doit etre un entier");
}
}
}
?> |
//voici mon programme principal:
Code:
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
| <?php
if(isset($_POST['envoyer'])){
/**************************************************************
Definition d'une fonction pour le nottaye des variables
***************************************************************/
function nettoyage($donnees){
$donnees = filter_var($donnees,FILTER_SANITIZE_FULL_SPECIAL_CHARS);//equivaut a htmlspecialchars
$donnees = filter_var($donnees, FILTER_SANITIZE_STRIPPED);//equivaut a strip_tags
$donnees = trim($donnees);//nettoyer les espaces inutiles
return $donnees;
}
/*####################################################################
Recuperation des informartions du formulaire
#####################################################################*/
$nom = nettoyage($_POST['nom']);
$prenom = nettoyage($_POST['prenom']);
$relation = $_POST['relation'];
$email = $_POST['email'];
$num_camtel = $_POST['numero_camtel'];
$num_mtn = $_POST['numero_mtn'];
$num_nexttel = $_POST['numero_nexttel'];
$num_orange = $_POST['numero_orange'];
$principal = $_POST['principal'];
$photo = $_FILES['image']['name'];
$taille_photo = $_POST['MAX_FILE_SIZE'];
/*\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
On verifie si les champs requis ont ete remplit
\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\*/
if(!empty($nom) && !empty($relation) && !empty($email) && !empty($principal)){
if(filter_var($email, FILTER_VALIDATE_EMAIL) !== false){
$email_valide = strtolower($email);
require'../includes/num_camtel.php';
require'../includes/num_mtn.php';
require'../includes/num_nexttel.php';
require'../includes/num_orange.php';
if(getNumCamtel()){
// Quand j'appel chaque fonction, ca verifie mais quan japel 2,3 ou 4 fct en mem tan, xa ne donne pas. aider moi
}elseif(getNumCamtel() && getNumMtn()){
//mais ca donne pas, ca verifie seulement une fonction, je sais pas pourquoi
}elseif(getNumMtn() && getNumOrange() && getNumNexttel()){
//mais ca donne pas, ca verifie seulement une fonction, je sais pas pourquoi
}else{
//code [par ] defo
}
}else{
header("Location:../index.php?erreur=Format E-mail invalide");
}
}else{
header("Location:../index.php?erreur=Remplissez les champs requis");
}
}
?> |