954,587 Members — Technology Publication meets Social Media
Username:
Password:
Lost login information?
Have something to say? Contribute New Article Reply to this Article

Help with my Register Script

<?php
require('./configs/reg_conf.php');
	function doesUsernameExist($name){
	    $exit = FALSE;
	    $result = @mssql_query("SELECT * FROM ACCOUNT_TBL WHERE account='$name'");
	    if (mssql_num_rows($result) != 0){
	        $exit = TRUE;
	    }
	    return $exit;
	}

	if(isset($_POST['submit'])){
	    $user = preg_replace ("[^A-Za-z0-9]", "", $_POST['username']);
	    $pass = preg_replace ("[^A-Za-z0-9]", "", $_POST['password']);
	    if($_POST['username'] == ""){
	        echo '<font color="red">Enter a user.</font>';
	    }
	    else if($_POST['password'] == ""){
			echo '<font color="red">Enter a password.</font>';
	    }
	    else if ((strlen($_POST['username']) > 16) || (strlen($_POST['username']) < 3)){
			echo '<font color="red">The user should be 3 to 16 characters.</font>';
	    }
	    else if ((strlen($_POST['password']) > 16) || (strlen($_POST['password']) < 3)){
			echo '<font color="red">The password should be 3 to 16 characters.</font>';
	    }
	    else if($_POST['username'] != $user){
			echo '<font color="red">User with invalid characters.</font>';
	    }
	    else if($_POST['password'] != $pass){
			echo '<font color="red">Password with invalid characters.</font>';
	    }
	    else {
			$pass = md5('serus' . $pass);
            if(!doesUsernameExist($user)){
                $stmt = mssql_init('createaccount', $link);
                mssql_bind($stmt, '@account', $user, SQLVARCHAR, false, false, 15);
                mssql_bind($stmt, '@password', $pass, SQLVARCHAR, false, false, 36);
                
                mssql_execute($stmt) or die ("Something is wrong on the execution");
                mssql_free_statement($stmt);
				echo '<font color="blue">Register Successfull.</font>';
            }
            else {
				echo '<font color="red">User already Exist.</font>';
            }
        }
		mssql_close();
    }
	
	echo '<form action="register.php" method="post">';
	echo 'Username: <input type="text" name="username" />';
	echo 'Password: <input type="password" name="password" />';
	echo '<input type="submit" name="submit" value="Register" />';
	echo '</form>';

?>
amras123
Newbie Poster
13 posts since Jan 2010
Reputation Points: 10
Solved Threads: 0
 

what's the problem?

farhan386
Light Poster
44 posts since Jul 2008
Reputation Points: 10
Solved Threads: 7
 

If you will post the dependent config files along with the database structure sql
we will be able to find out exactly the issues. And try to arrive at a solution.

sourcebits
Junior Poster
102 posts since Dec 2008
Reputation Points: 16
Solved Threads: 14
 

This article has been dead for over three months

Post: Markdown Syntax: Formatting Help
You