I'm still new to PHP, and i've already tried several solutions but i seem to miss a point here. I have 2 warnings, and 1 fatal error. I'm more interested in the 2 warnings, but any help is welcomed.

( ! ) Warning: include_once(model/register/register_member.php): failed to open stream: No such file or directory in C:\wamp\www\controller\register\index.php on line 3

( ! ) Warning: include_once(): Failed opening 'model/register/register_member.php' for inclusion (include_path='.;C:\php\pear') in C:\wamp\www\controller\register\index.php on line 3 ( ! ) Fatal error: Call to a member function prepare() on a non-object in C:\wamp\www\controller\register\index.php on line 20

My 5 files : (Which all are in C:\wamp\www)


function register_member($pseudo, $pass_hache, $email) {
    global $db;
    $req = $db->prepare('INSERT INTO membres(pseudo, password, email, date_inscription) VALUES(:pseudo, :password, :email, CURDATE())');
        'pseudo' => $pseudo,
        'email' => $email));
        'password' => $pass_hache,


if(isset($_POST['inscription'])) {
    // On rend inoffensif les données de l'utilisateur
    $_POST['pseudo'] = htmlspecialchars($_POST['pseudo']);
    $_POST['password'] = htmlspecialchars($_POST['password']);
    $_POST['password2'] = htmlspecialchars($_POST['password2']);
    $_POST['email'] = htmlspecialchars($_POST['email']);
     * Vérification si le pseudo est disponible
    global $db;
    $req = $db->prepare('SELECT pseudo FROM membres WHERE pseudo = ?');
    $resultat = $req->fetch();
    if (!$resultat) {
        $pseudo = $_POST['pseudo'];
    } else {
     * Vérification de la validité de l'adresse mail
    if (isset($_POST['email'])) {
        $_POST['email'] = htmlspecialchars($_POST['email']); // On rend inoffensives les balises HTML que le visiteur a pu rentrer
        if (preg_match("#^[a-z0-9._-]+@[a-z0-9._-]{2,}\.[a-z]{2,4}$#", $_POST['email'])) {
            $email = $_POST['email'];
        } else {
            //echo 'L\'adresse ' . $_POST['mail'] . ' n\'est pas valide, recommencez !';
            //header('Location: mypage.php');
     * Vérification si le mdp est correct
    if (!($_POST['password'] == $_POST['password2']))
     * Hachage du mot de passe
    $pass_hache = sha1($_POST['password']);
    $pseudo = $_POST['pseudo'];
    $email = $_POST['email'];
    register_member($pseudo, $pass_hache, $email);
    echo 'Vous avez été inscrits !';


<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <h3>Inscrition à l'espace membre.</h3>
        <form action="controller/register/index.php" method="post">
                <p><label for="pseudo">Pseudo :</label> <input type="text" id="pseudo" name="pseudo" /></p>
                <p><label for="pass">Mot de passe : </label> <input type="password" id="pass" name="password" /></p>
                <p><label for="verif_pass">Retapez votre mot de passe : </label> <input type="password" id="password2" name="password2" /></p>
                <p><label for="email">Adresse email :</label> <input type="text" id="email" name="email" /></p>
                <input type="submit" value="Inscription" name="inscription" />

register.php (in root)

/*if (!isset($_GET['section']) OR $_GET['section'] == 'index')

And of course, a file to connect to the DB (model/connexion_ident_conn.php). I know that the quality of my code is really bad, i'm going to rewrite everything in OOP. But i'm really interested in what i'm missing now.

Thank you very much.

Related posts

Recent Viewed