Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Page 1 of 2 12 LastLast
Results 1 to 15 of 16
  1. #1
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Simple Help Reg page connected to mssql DB

    Hey Friends i need a big favor i paid for a dedicated server with out knowing that the server i was going to host required a registration page.

    The Server is done in MsSql
    All i really need is something simpler then this and how to work it?

    Gonna get killed for posting another link but i didn't wanna post the full code..

    Thanks in advance

    http://forum.ragezone.com/f772/reg-s...op-ppl-813662/

  • #2
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I've got this far


    http://cdandl.us/register.htm

  • #3
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    bump??

  • #4
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    I don't understand what you mean by "host required a registration page". If you've got a dedicated or a VPS, then there's really no requirement for you to install anything on it.

    Post the code here, make sure you surround it with [php][/php] tags to preserve the formatting. Its too hard to read there.
    Then you need to tell us what the actual issue is. Nobody will rewrite the code or convert the database engine or anything like that, but if you have an error then we can help you fix that.

  • #5
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Well im hosting a game server on mssql.
    To link from a Registration page that sends an account name and password people choose

    PHP Code:

    <?php

    $cfg
    ['sql_host'] = "CUSTOMER-PC\SQLEXPRESS";
    $cfg['sql_user'] = "Myusername";
    $cfg['sql_pass'] = "Mypassword";
    $cfg['sql_db'] = "SRO_VT_Account";


    $sqlLink mssql_connect($cfg[sql_host],$cfg[sql_user],$cfg[sql_pass]);
        if(!
    $sqlLink) die("MSSQL server is not accessable, why should we try to select database ?");
            else
            {
                
    mssql_select_db($cfg[sql_db],$sqlLink);
            }
    ?>

  • #6
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Okay, don't use mssql at all. The package is old, and I don't believe they intend to keep it around much longer. I'd recommend for a concrete implementation that you use SQLSRV.

    Other than that, you didn't really specify what you are needing to do / the error you have with the above. Although lacking the mssql extension wouldn't surprise me which is why I suggested looking into the SQLSRV. You can also look into PDO, but I'm not sure what the SQLServer drivers are like for support on it.

  • #7
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    That version of sql is the only version that will run the server files correctly and i keep getting an error of not connecting to database

  • #8
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Change this:
    PHP Code:
        if(!$sqlLink) die("MSSQL server is not accessable, why should we try to select database ?"); 
    To this:
    PHP Code:
        if(!$sqlLink) die("Failed to connect: " mssql_get_last_message()); 
    I assume you can fetch an error off of a mssql_connect. If it produces no cause for the failed to connect message, you'll need to check your sqlserver logs.

  • #9
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Always get this error

    Fatal error: Call to undefined function mssql_connect() in D:\Hosting\9503144\html\_inc\config.php on line 9

  • #10
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Main code
    PHP Code:
     <?php
    /* Simple registration page for silkroad server, by Chernobyl
     * Settings are at _inc/config.php
     * If you get an mssql connection error, while defining totally correct data
     * Just use older ntwdblib.dll for your webserver
    */
    require_once('_inc/security.class.php');
    require_once(
    '_inc/config.php');

    if(!isset(
    $_POST['submit']))
        {
            echo 
    "<table border='1'>
            <form method='post'>
            <td>Username</td><td><input type='text' name='username' maxlength='16'></td><tr/>
            <td>Password[1]</td><td><input type='password' name='pw1' maxlength='32'></td><tr/>
            <td>Password[2]</td><td><input type='password' name='pw2' maxlength='32'></td><tr/>
            <td></td><td><input type='submit' name='submit' value='Register'></td>
            </form>
                    </table>"
    ;
        }
        else
        {
                    if(
    is_array($user) == true$err[] = "Username is array, n00p";
            if(
    is_array($pass1) == true$err[] = "Pw1 is array, n00p";
            if(
    is_array($pass2) == true$err[] = "Pw2 is array, n00p";
            if(
    strlen($_POST['username']) < 3$msg[] = "Username too short";
            if(
    strlen($_POST['username']) > 16)$msg[] = "Username too long";
            if(
    strlen($_POST['pw1']) < 6$msg[] = "Password [1] too short";
            if(
    strlen($_POST['pw1']) > 32)$msg[] = "Password [1] too long";
            if(
    strlen($_POST['pw2']) < 6$msg[] = "Password [2] too short";
            if(
    strlen($_POST['pw']) > 32$msg[] = "Password [2] too long";
            if(
    $_POST['pw1'] != $_POST['pw2']) $msg[] = "Passwords are not the same";
            
                
    $sec = new security();
                
                if(
    $sec->is_secure($_POST['username']) == false$msg[] = "Username contains forbidden symbols";
                if(
    $sec->is_secure($_POST['pw1']) == false$msg[] = "Password [1] contains forbidden symbols";
                if(
    $sec->is_secure($_POST['pw2']) == false$msg[] = "Password [2] contains forbidden symbols";
                
                if(
    count($msg) > 0)
                    {
                        for(
    $i 0$i count($msg); $i++)
                            {
                                echo 
    $msg[$i]."<br/>";
                            }
                            return;
                    }
                    else
                        {
                            
    //checking damn mssql stuff
                            
    $accountExists mssql_num_rows(mssql_query("select StrUserID from TB_User where StrUserID='$_POST[username]'"));
                                if(
    $accountExists 0) echo "Account with such username already exists<br/>";
                                    else
                                    {
                                        
    $pwd md5($_POST['pw1']);
                                        
    mssql_query("insert into TB_User(StrUserID,password,sec_primary,sec_content) values('$_POST[username]','$pwd','3','3')");
                                            echo 
    "Account successfully created<br/>";
                                    }
                        }

        }
    ?>


    _inc/security.class.php
    PHP Code:
     <?php
    class security
    {
    function 
    is_secure($string)
                {
                
    $pattern "#[^a-zA-Z0-9_\-]#";
                    if(
    preg_match($pattern,$string)==true)return false;
                            else
                            return 
    true;
                    }            
    }
    ?>




    Code you told me to fix
    _inc/config
    PHP Code:
    <?php

    $cfg
    ['sql_host'] = "CUSTOMER-PC\SQLEXPRESS";
    $cfg['sql_user'] = "*******";
    $cfg['sql_pass'] = "*******";
    $cfg['sql_db'] = "SRO_VT_Account";


    $sqlLink mssql_connect($cfg[sql_host],$cfg[sql_user],$cfg[sql_pass]);
        if(!
    $sqlLink) die("Failed to connect: " mssql_get_last_message());  
            else
            {
                
    mssql_select_db($cfg[sql_db],$sqlLink);
            }
    ?>

  • #11
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by teemo87 View Post
    Always get this error

    Fatal error: Call to undefined function mssql_connect() in D:\Hosting\9503144\html\_inc\config.php on line 9
    You don't have mssql installed. You'll need to consult the documentation here for installing it. The requirements section is the most important part of this package; installation on windows is a simple matter of uncommenting the line in php.ini to enable it, but you require the dll's on the system path to run it.

  • #12
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I have mssql installed on my server pc that is what my server is running off of.

  • #13
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by teemo87 View Post
    I have mssql installed on my server pc that is what my server is running off of.
    The error says you do not have mssql extension installed.
    You may have SQLServer installed as a database, but you need to configure PHP to use mssql extension.

  • #14
    New Coder
    Join Date
    Oct 2012
    Posts
    10
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks for the help so far ill test and see what i can do
    thanks again

  • #15
    God Emperor Fou-Lu's Avatar
    Join Date
    Sep 2002
    Location
    Saskatoon, Saskatchewan
    Posts
    16,987
    Thanks
    4
    Thanked 2,660 Times in 2,629 Posts
    Quote Originally Posted by teemo87 View Post
    Thanks for the help so far ill test and see what i can do
    thanks again
    Your welcome.
    Interesting note I hadn't seen:
    This extension is not available anymore on Windows with PHP 5.3 or later.
    According to this, you need to use 5.2x or older version of PHP in order to use mssql extension. Otherwise you'll need to rewrite the code in PDO or SQLSrv (even odbc would work). I knew it was going away, but I didn't think it was actually gone.


  •  
    Page 1 of 2 12 LastLast

    Posting Permissions

    • You may not post new threads
    • You may not post replies
    • You may not post attachments
    • You may not edit your posts
    •