Пример #1
0
function loadAllMessagesForUsername($username)
{
    if (!accountExists($username)) {
        return FALSE;
    }
    $messagesFileName = messageFilenameForUsername($username);
    if (file_exists($messagesFileName)) {
        $jsonData = file_get_contents($messagesFileName);
        $messagesData = json_decode($jsonData);
        return $messagesData;
    } else {
        return array();
    }
}
Пример #2
0
                        <input required type="text" name="username" placeholder="Username"/>
                    </div>
                </div>
                <div class="field">
                    <div class="ui left icon input">
                        <i class="lock icon"></i>
                        <input required type="password" name="password" placeholder="Password"/>
                    </div>
                </div>
                <input class="ui blue fluid large submit button" type="submit" name="submit" value="Login"/>
            </div>
        </form>
<?php 
if (isset($_POST['submit'])) {
    //Make sure the no other record contains the same username.
    if (!accountExists()) {
        drawError("Invalid username/password combination");
    } else {
        $link = mysqli_connect("host_name", "username", "password", "database") or die("Database connection failed - " . mysqli_error($link));
        $sql = "SELECT salt, hashed_password, isAdmin, userID FROM user WHERE username = UPPER(?) ";
        if ($stmt = mysqli_prepare($link, $sql)) {
            $user = $_POST['username'];
            mysqli_stmt_bind_param($stmt, "s", $user) or die("bind param");
            mysqli_stmt_execute($stmt);
            mysqli_stmt_bind_result($stmt, $salt, $hpass, $isAdmin, $userID);
            mysqli_stmt_store_result($stmt);
            mysqli_stmt_fetch($stmt);
        } else {
            die("MySQLi prepare failed");
        }
        mysqli_stmt_close($stmt);
    // if everything is ok, try to upload file
    } else {
        if (move_uploaded_file($_FILES["image"]["tmp_name"], $target_file)) { */
 // Ajout du film à la bd
 $user_pseudo = $_POST["pseudo"];
 $user_login = $_POST["login"];
 $user_mdp = $_POST["mdp"];
 $user_mdp2 = $_POST["mdp2"];
 $user_mail = $_POST["mail"];
 if ($user_mdp != $user_mdp2) {
     echo '
                 <div class="alert alert-danger">
                   <strong>Fail!</strong> Les mots de passes doivent correspondre, Jean-Hubert.
                 </div>';
 } else {
     if (accountExists($idConnexion, $user_pseudo, $user_login, $user_mail)) {
         echo '
             <div class="alert alert-danger">
               <strong>Fail!</strong> T\'as déja un compte sur ce site, Jean-Philippe.
             </div>';
     } else {
         //$mov_image = $_FILES["image"]["name"];
         ajouterUser($idConnexion, $user_pseudo, $user_login, $user_mdp, $user_mail);
         echo ' 
             <div class="alert alert-success">
               <strong>Success!</strong> Votre compte a bien été créé.
             </div>';
     }
 }
 /* IMAGE POUR PLUS TARD
          }
    </head>
<body>
        <script>
                $(document).ready(function() {
                        $('#country_select').dropdown();   
                });
        </script>
    <div class="ui middle aligned center aligned grid">
    <div class="column">
            <h2 class="ui header">
                <div class="content">User Registration</div>
            </h2>   
<?php 
if (isset($_POST['submit'])) {
    //Make sure the no other record contains the same username.
    if (accountExists()) {
        echo '<div id="err-msg" class="ui error message">Sorry, that username already exists. Please choose a different username.</div>';
    } else {
        $link = mysqli_connect("host_name", "username", "password", "database") or die("Connection Error " . mysqli_error($link));
        $sql = "INSERT INTO user(username,salt,hashed_password,firstname,lastname,email,age,gender,loc_city,loc_state,loc_country, status) VALUES ( UPPER(?),?,?,?,?,?,?,?,?,?,?,?)";
        if ($stmt = mysqli_prepare($link, $sql)) {
            $user = htmlentities($_POST['username']);
            $salt = mt_rand();
            $hpass = password_hash($salt . $_POST['password'], PASSWORD_BCRYPT) or die("bind param");
            $firstname = htmlentities($_POST['firstname']);
            $lastname = htmlentities($_POST['lastname']);
            $email = htmlentities($_POST['email']);
            $age = htmlentities($_POST['age']);
            $gender = htmlentities($_POST['gender']);
            $city = htmlentities($_POST['city']);
            $state = htmlentities($_POST['state']);