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:

<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:

<?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

[size=xsmall]Toevoeging op 28/09/2013 14:59:22:[/size]

bumb heb egt hulp nodig

Reageren