Availability Check in Registration

Overzicht Reageren

Sponsored by: Vacatures door Monsterboard

Nicolai Van der Storm

Nicolai Van der Storm

27/09/2013 20:34:23
Quote Anchor link
hallo zoals de titel al zegt zou ik in men registratie form een Availability Check in Registration willen in ajax ofzo.
ik heb al verschillde geprobeerd maar zonder success.
dus kom ik hier ff hulp vraagen :D
en als het mogelijk is een mooie popup als bevestiging van de registratie .


form.php:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
54
55
56
57
58
59
60
61
<html>
<head>
</head>
<body>    
    <div id="myModal" class="modal hide fade" tabindex="-1" role="dialog" aria-labelledby="myModalLabel" aria-hidden="true">
        <div class="modal-header">
            <button type="button" class="close" data-dismiss="modal" aria-hidden="true"></button>
                <h3 id="myModalLabel">Beta Sign up,</h3>
        </div>
        <div class="modal-body">            
                    <center>
                    <br />
                                    
                        <form class="form-horizontal" id='register' action='register.php' method='post' accept-charset='UTF-8'>
                            <fieldset>
                                <div class="help-block"></div>
                                    <div class="input-prepend">
                                        <span class="add-on check"><i class="icon-user"></i></span>
                                        <input type='text' name='username' id='username' placeholder="Username">
                                    </div>
                                
                                <div class="help-block"></div>
                                    <div class="input-prepend">
                                        <span class="add-on"><i class="icon-lock"></i></span>
                                        <input type='password' name='password' id='password' placeholder="Password">
                                    </div>
                                
                                <div class="help-block"></div>
                                    <div class="input-prepend">
                                        <span class="add-on"><i class="icon-envelope"></i></span>
                                        <input type='text' name='email' id='email' placeholder="E-Mail">
                                    </div>
                                    
                                <div class="help-block"></div>
                                    <div class="input-prepend">
                                        <span class="add-on"><i class="icon-th"></i></span>
                                        <input type='text' name='mc' id='mc' placeholder="Mc Username">
                                    </div>
                                
                                <div class="help-block"></div>
                                    <div class="input-prepend">
                                        <span class="add-on"><i class="icon-wrench"></i></span>
                                            <select name="roll" id="roll">
                                                <option value="BetaTester">Beta Tester</option>
                                                <option value="Coder">Coder</option>
                                            </select>
                                    </div>
                            <hr>
                                <div class="help-block">
                                    <button type="submit" class="btn btn-large btn-info">Request an Invite</button>
                                </div>
                            </fieldset>
                        </form>
                    </center>
        </div>
            <div class="modal-footer">
                <p> 2013 HyperGainZ</p>
            </div>
    </div>
</body>
</html>


register.php:
Code (php)
PHP script in nieuw venster Selecteer het PHP script
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
<?php
    require("config.php");
    if(!empty($_POST))
    {

        // Ensure that the user fills out fields
         $test = file_get_contents("http://minecraft.net/haspaid.jsp?user=".$_POST['mc']);
        if($test != "true")
        {
die("Please enter a valid Minecraft username."); }
        if(empty($_POST['username']))
        {
die("Please enter a username."); }
        if(empty($_POST['password']))
        {
die("Please enter a password."); }
        if(!filter_var($_POST['email'], FILTER_VALIDATE_EMAIL))
        {
die("Invalid E-Mail Address"); }
          
        // Check if the username is already taken
        $query = "
            SELECT
                1
            FROM beta_users
            WHERE
                username = :username
        "
;
        $query_params = array( ':username' => $_POST['username'] );
        try {
            $stmt = $db->prepare($query);
            $result = $stmt->execute($query_params);
        }

        catch(PDOException $ex){ die("Failed to run query: " . $ex->getMessage()); }
        $row = $stmt->fetch();
        if($row){ die("This username is already in use"); }
        $query = "
            SELECT
                1
            FROM beta_users
            WHERE
                email = :email
        "
;
        $query_params = array(
            ':email' => $_POST['email']
        );

        try {
            $stmt = $db->prepare($query);
            $result = $stmt->execute($query_params);
        }

        catch(PDOException $ex){ die("Failed to run query: " . $ex->getMessage());}
        $row = $stmt->fetch();
        if($row){ die("This email address is already registered"); }
          
        // Add row to database
        $query = "
            INSERT INTO beta_users (
                username,
                password,
                salt,
                email,
                mc,
                roll
            ) VALUES (
                :username,
                :password,
                :salt,
                :email,
                :mc,
                :roll
            )
        "
;
          
        // Security measures
        $salt = dechex(mt_rand(0, 2147483647)) . dechex(mt_rand(0, 2147483647));
        $password = hash('sha256', $_POST['password'] . $salt);
        for($round = 0; $round < 65536; $round++){ $password = hash('sha256', $password . $salt); }
        $query_params = array(
            ':username' => $_POST['username'],
            ':password' => $password,
            ':salt' => $salt,
            ':email' => $_POST['email'],
            ':mc' => $_POST['mc'],
            ':roll' => $_POST['roll']
        );

        try {  
            $stmt = $db->prepare($query);
            $result = $stmt->execute($query_params);
        }

        catch(PDOException $ex){ die("Failed to run query: " . $ex->getMessage()); }
        header("Location: index.php");
        die("Redirecting to index.php");
    }

?>


ps. ik gebruik twitter bootstrap 2.3.2 als style : live demo :http://test.hypergainz.eu/index.php (form is de "join the beta" knop

mvg Nicolai

Toevoeging op 28/09/2013 14:59:22:

bumb heb egt hulp nodig
 
Er zijn nog geen reacties op dit bericht.



Overzicht Reageren

 
 

Om de gebruiksvriendelijkheid van onze website en diensten te optimaliseren maken wij gebruik van cookies. Deze cookies gebruiken wij voor functionaliteiten, analytische gegevens en marketing doeleinden. U vindt meer informatie in onze privacy statement.