Пример #1
0
    }
    function AjouterAdmin($admin)
    {
        $Requete = "insert into utilisateur\n\t\t(nom,prenom,age,type,login,pwd)values\n\t\t(\n\t\t'" . $admin->getNom() . "',\n\t\t'" . $admin->getPrenom() . "',\n\t\t'" . $admin->getAge() . "',\n\t\t\t\t'admin',\n\t\t'" . $admin->login . "',\n\t\t\t\t'" . $admin->pwd . "'\n\t\t);";
        $this->conn->exec($Requete);
    }
    function verifPassword($pwd, $confirmpwd)
    {
        if ($pwd == $confirmpwd) {
            $success = true;
        } else {
            $success = false;
        }
        return $success;
    }
}
$login = $_POST['login'];
$pwd = $_POST['password'];
$confirmP = $_POST['conpassword'];
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$age = $_POST['age'];
$admin = new admin($nom, $prenom, $age, $login, $pwd);
$m = new AjoutAdmin();
$verifpwd = $m->verifPassword($pwd, $confirmP);
if ($verifpwd) {
    $m->AjouterAdmin($admin);
    header('location:authentification.html');
} else {
    echo "Password and Confirm password not match";
}
Пример #2
0
<?php

include 'Admin.php';
include 'Config.php';
class AjoutAdmin
{
    public $conn;
    function __construct()
    {
        $c = new Config();
        $this->conn = $c->connexion();
    }
    function ajout($admin)
    {
        $req = "insert into utilisateur(nom,prenom,age,login,password) values\n\t\t \t\t('" . $admin->getNom() . "',\n\t\t\t\t'" . $admin->getPrenom() . "',\n\t\t\t\t'" . $admin->getAge() . "',\n\t\t\t\t'" . $admin->login . "',\n\t\t\t\t'" . $admin->password . "'\n\t\t\t\t);";
        $this->conn->exec($req);
    }
}
$a = new AjoutAdmin();
$nom = $_POST['nom'];
$prenom = $_POST['prenom'];
$age = $_POST['age'];
$login = $_POST['login'];
$password = $_POST['password'];
$admin = new Admin($nom, $prenom, $age, $login, $password);
$a->ajout($admin);
echo $nom;
echo $prenom;