register script

Results 1 to 1 of 1
  1. #1
    Elite Member olo3007 is offline
    Member +Rank
    Jul 2009 Join Date
    ℋȺȾȜɌLocation
    108Posts

    register script

    Hello i have problem with register script.All mssql/odbcs are good but can't make account because:


    Warning: odbc_connect() [function.odbc-connect]: SQL error: [Microsoft][ODBC Driver Manager] Data source name not found and no default driver specified, SQL state IM002 in SQLConnect in C:\xampp\htdocs\register\index.php on line 63

    Warning: odbc_exec() expects parameter 1 to be resource, boolean given in C:\xampp\htdocs\register\index.php on line 81

    Warning: odbc_fetch_array() expects parameter 1 to be resource, null given in C:\xampp\htdocs\register\index.php on line 88

    Here Script :
    <?php
    /**
    * Registration handling
    *
    * @author Claus Jřrgensen <thedeathart@gmail.com>
    * @category Common
    * @package Kalonline Registration
    * @copyright Copyright (c) 2006 Claus Jřrgensen (http://dragons-lair.org)
    * @license MIT License
    */

    include 'Password.php'; // password class
    include 'Captcha.php'; // captcha class

    session_start(); // required for captcha to work

    // error reporting
    error_reporting(E_ALL);
    ini_set('display_errors','on');

    // configuration
    $config = array(
    'db_username' => 'sa', // database username
    'db_password' => '*******', // database password
    'db_dsn' => 'kal_auth', // system DSN to the database
    'template' => 'registration.tpl', // registration template path/filename
    'debug' => false, // show SQL errors if true
    );

    // HTML error
    define('UI_ERROR','<span class="error">%s</span>');

    // if we need to output a captcha
    if(isset($_GET['captcha'])) {
    $captcha = new Captcha(120,40,6);
    }

    // if submitted
    if(strtolower($_SERVER['REQUEST_METHOD']) == 'post') {
    $username = $_POST['username'];
    $password = $_POST['password'];
    $captcha = $_POST['captcha'];

    $error = array();
    // validate username
    if(!ctype_alnum($username)) {
    $error['username'] = sprintf(UI_ERROR,'Illigal characters in the username');
    }
    // validate password
    if(!ctype_alnum($password)) {
    $error['password'] = sprintf(UI_ERROR,'Illigal characters in the password');
    }
    // validate captcha
    if($captcha != $_SESSION['captcha']) {
    $error['captcha'] = sprintf(UI_ERROR,'Wrong security code');
    }

    // no errors, continue to username check
    if(empty($error)) {
    // db connect
    $conn = odbc_connect($config['db_dsn'],
    $config['db_username'],
    $config['db_password']);
    // check about account name is taken
    $check = "SELECT
    [ID] FROM [Login]
    WHERE
    [ID]='%s'
    OR
    [ID]='%s'
    OR
    [ID]='%s'
    OR
    [ID]='%s'
    ";
    $check = sprintf($check,$username,
    strtolower($username),
    strtoupper($username),
    ucfirst($username)
    );
    $exec = odbc_exec($conn,$check);
    // check for errors
    if(!$exec && ($config['debug'] === true)) {
    echo odbc_errormsg($conn);
    die();
    }
    // is the account registered?
    $data = odbc_fetch_array($exec);
    if($data !== false) {
    $error['username'] = sprintf(UI_ERROR,'Account already registered,
    please choose another name');
    } else { // else continue
    // encode password
    $password = Password::encode($password);
    // prepare sql
    $sql = "INSERT INTO
    [Login] ([ID],[PWD],[Birth],[Type],[ExpTime],[Info])
    VALUES
    ('".$username."',".$password.",'19190101',0,4000,0)
    ";
    // insert user
    $result = odbc_exec($conn,$sql);
    if(!$result && ($config['debug'] === true)) {
    echo odbc_errormsg($conn);
    die();
    }
    }
    }
    }

    // display template
    include $config['template'];

    ?>
    Last edited by olo3007; 16-10-10 at 06:52 PM.




Advertisement