return :
 			true if available
 			false if not available
 		$db -> 				database object
 		$email -> 			field value : email
 	*/
 $email_ok = isEmailAvailable($db, $email);
 /* isUsernameAvailable
 		return :
 			true if available
 			false if not available
 		$db -> 				database object
 		$username -> 			field value : username
 
 	*/
 $username_ok = isUsernameAvailable($db, $username);
 if ($email_ok && $username_ok) {
     /* userRegistration
     			return :
     				true for registration OK
     				false for fail
     			$db -> 				database object
     			$username -> 		field value : username
     			$email -> 			field value : email
     			$password -> 		field value : password
     		*/
     userRegistration($db, $username, $email, $password);
     header('Location: login.php');
 }
 if (!$email_ok) {
     $error = 'echec de l inscription';
 /* isEmailAvailable
 			return :
 				true if available
 				false if not available
 			$db -> 				database object
 			$email -> 			field value : email
 		*/
 $email_ok = isEmailAvailable($db, $_POST['email']);
 /* isUsernameAvailable
 			return :
 				true if available
 				false if not available
 			$db -> 				database object
 			$username -> 			field value : username
 		*/
 $username_ok = isUsernameAvailable($db, $_POST['username']);
 if ($email_ok == true && $username_ok == true) {
     /* userRegistration
     				return :
     					true for registration OK
     					false for fail
     				$db -> 				database object
     				$username -> 		field value : username
     				$email -> 			field value : email
     				$password -> 		field value : password
     			*/
     userRegistration($db, $_POST['username'], $_POST['email'], $_POST['password']);
     header('Location: login.php');
 }
 if (!$email_ok) {
     $error = 'Email indisponible';
<?php

require 'config/config.php';
require 'model/functions.fn.php';
session_start();
if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) {
    if (isUsernameAvailable($db, $_POST['username']) === true) {
        if (isEmailAvailable($db, $_POST['email']) === true) {
            userRegistration($db, $_POST['username'], $_POST['email'], $_POST['password']);
        } else {
            echo "l'email n'est pas disponible";
        }
    } else {
        echo 'l\'username est deja n\'est pas disponible';
    }
} else {
    $_SESSION['message'] = 'Erreur : Formulaire incomplet';
    header('Location: register.php');
}
echo 'salut ';
<?php

require 'config/config.php';
require 'model/functions.fn.php';
session_start();
if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) {
    if (isUsernameAvailable($db, $_POST['username']) && isEmailAvailable($db, $_POST['email'])) {
        userRegistration($db, $_POST['username'], $_POST['email'], $_POST['password']);
        header('Location: login.php');
    } else {
        header('Location: register.php');
        $_SESSION['message'] = 'Erreur: username ou email déjà pris.';
    }
} else {
    $_SESSION['message'] = 'Erreur : Formulaire incomplet';
    header('Location: register.php');
}
Example #5
0
?>
<html>
<head>
<script type="text/javascript" src="https://www.google.com/jsapi"></script><script type="text/javascript">
        google.load( "jquery", "1" );
        google.load( "jqueryui", "1" );
</script>
<link rel="stylesheet" type="text/css" href="new/fcn.css"/>
<link rel="stylesheet" type="text/css" href="new/jquery-ui.css"/>
<body style="background-color:#fff;font-size:1em;">
<div style="width:50%;margin-left:auto;margin-right:auto;">
<h1>Signup Results</h1>
<?php 
// Possible improvement: all this validation really could be happening via JavaScript
// before form submission.
if (!isUsernameAvailable($r_username)) {
    // See if the username is taken
    echo "Sorry, but the collector name <b>" . $r_username . "</b> is already taken.  Please go ";
    echo "<a href=\"javascript:window.history.back();\">back</a> and try again.";
} elseif (strlen($r_password) < 6) {
    // Minimum password length is 6 characters.  Please fix this magic number
    echo "Your password must be at least 6 characters long.  Please go ";
    echo "<a href=\"javascript:window.history.back();\">back</a> and try again.";
} elseif (strcmp($r_password, $r_password_confirm) != 0) {
    // Compare the password and the confirmation password...
    echo "Sorry, but your passwords don't match.  Please go ";
    echo "<a href=\"javascript:window.history.back();\">back</a> and try again.";
} elseif (!isEmailValid($r_email)) {
    // Call the isEmailValid() function (defined in functions.php) to see if the email
    // matches regexps for a valid address.
    echo "Invalid email address.  Please go ";
<?php

require 'config/config.php';
require 'model/functions.fn.php';
session_start();
if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) {
    // TODO
    $username = $_POST["username"];
    $password = $_POST["password"];
    $email = $_POST["email"];
    if (isUsernameAvailable($db, $username) === true) {
        if (isEmailAvailable($db, $email) === true) {
            userRegistration($db, $username, $email, $password);
            $_SESSION['message'] = "bravo !";
            header('Location: login.php');
        } else {
            $_SESSION['message'] = "email deja utilisé";
            header('Location: register.php');
        }
    } else {
        $_SESSION['message'] = "username deja utilisé";
        header('Location: register.php');
    }
} else {
    $_SESSION['message'] = 'Erreur : Formulaire incomplet';
    header('Location: register.php');
}
<?php

require 'config/config.php';
require 'model/functions.fn.php';
session_start();
if (isset($_POST['username']) && isset($_POST['email']) && isset($_POST['password']) && !empty($_POST['username']) && !empty($_POST['email']) && !empty($_POST['password'])) {
    // TODO
    $username = $_POST['username'];
    $email = $_POST['email'];
    $password = $_POST['password'];
    if (isUsernameAvailable($db, $username)) {
        if (isEmailAvailable($db, $email)) {
            userRegistration($db, $username, $email, $password);
            $_SESSION['message'] = 'Successful !';
        } else {
            $_SESSION['message'] = 'email deja utilis�';
        }
    } else {
        $_SESSION['message'] = 'username deja utilis�';
    }
    header('Location: register.php');
} else {
    $_SESSION['message'] = 'Erreur : Formulaire incomplet';
    header('Location: register.php');
}
 /* isEmailAvailable
 		return :
 			true if available
 			false if not available
 		$db -> 				database object
 		$email -> 			field value : email
 	*/
 $email_ok = isEmailAvailable($db, "*****@*****.**");
 /* isUsernameAvailable
 		return :
 			true if available
 			false if not available
 		$db -> 				database object
 		$username -> 			field value : username
 	*/
 $username_ok = isUsernameAvailable($db, "Git");
 if ($email_ok && $username_ok) {
     /* userRegistration
     			return :
     				true for registration OK
     				false for fail
     			$db -> 				database object
     			$username -> 		field value : username
     			$email -> 			field value : email
     			$password -> 		field value : password
     		*/
     userRegistration($db, "Git", "*****@*****.**", "password");
     header('Location: login.php');
 }
 if (!$email_ok) {
     //