Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <form method="post" action="" enctype="multipart/form-data" onSubmit="registeruser()">
- <div>
- Username <span class="required">*</span><br/> <input class="registerinputbox" type="text" name="username" size="20"/><br/>
- Password <span class="required">*</span><br/> <input class="registerinputbox" type="password" name="password" size="20"/><br/>
- E-Mail <span class="required">*</span><br/> <input class="registerinputbox" type="text" name="email" size="20"/><br/>
- <input class="registerbutton" type="submit" name="registerbutton" value="Register"/> <span class="required">*</span> = required
- </div>
- </form>
- ----------------------------------------------------------------------------
- function registeruser() {
- if (document.getElementById("content").value == "") {
- return false;
- }
- if (window.XMLHttpRequest) {
- var xhr = new XMLHttpRequest();
- }
- else {
- var xhr = new ActiveXObject("Microsoft.XMLHTTP");
- }
- xhr.onreadystatechange = function() {
- if (xhr.readyState == 4) {
- var posts = xhr.responseText;
- document.getElementById("content").innerHTML = posts;
- }
- else {
- document.getElementById("content").innerHTML ='<img src="ajax-loader.gif"/>';
- }
- }
- xhr.open("GET", "registeruser.php");
- xhr.send(null);
- document.getElementById("content").style.display='block';
- }
- ----------------------------------------------------------------------
- <?php
- $conn = blah;
- $username = mysqli_real_escape_string($conn,strip_tags($_POST['username']));
- $password = mysqli_real_escape_string($conn,strip_tags($_POST['password']));
- $email = mysqli_real_escape_string($conn,strip_tags($_POST['email']));
- if (strlen($username) > 15) {
- echo "The username you are trying to register is over the max of 15 characters, please go <a href='javascript:register()'>back</a> and try agian." ;
- die;
- }
- if (strlen($password) > 15) {
- echo "The password you are trying to register is over the max of 15 characters, please go <a href='javascript:register()'>back</a> and try agian." ;
- die;
- }
- if (strlen($email) > 35) {
- echo "The email you are trying to register is over the max of 35 characters, please go <a href='javascript:register()'>back</a> and try agian." ;
- die;
- }
- $sp_checkuserdb = "CALL checkuserdb('$username','$email')";
- $rs_checkuserdb = mysqli_query($conn, $sp_checkuserdb);
- $checkuserdb_result = mysqli_num_rows($rs_checkuserdb);
- if ($checkuserdb_result >= 1) {
- echo $username;
- echo "The username or email you are trying to register is already in use, please go <a href='javascript:register()'>back</a> and try agian." ;
- die;
- }
- $conn = blah;
- $sp_registeruser = "CALL registeruser('$username','$password','$email')";
- $run_registeruser = mysqli_query($conn, $sp_registeruser);
- echo "Thanks for registering, you may now login and begin posting!" ;
- ?>
Add Comment
Please, Sign In to add comment