Safe registration script
#10

Replace: (line 66)

( $conf[use_encryption] ? $pass = md5( $_POST[pass1] ) : $pass = $_POST[pass1] )

To:

( $conf[use_encryption] ? $pass = md5( $_POST[pass1] ) : $pass = $_POST[pass1] );

 

And...

This (line 100)

colspan="2">

to

 

Full code:

<?php

// Settings to change
$conf[db][server] = ;
$conf[db][dbase] = ;
$conf[db][user] = ;
$conf[db][pass] = ;

// Set this to true if u want to use encrypted passwords in the database.
// Your Engine.dll must support this in order to set it to true.
// Its highly recommended to use it

$conf[use_encryption] = false;

// Dont change below here unless u know what u are doing -------------------------------------------------------------------

$conf[db][dsn] = sprintf("mysql:host=%s;dbname=%s", $conf[db][server], $conf[db][dbase]);

try
{
$db = new PDO($conf[db][dsn], $conf[db][user], $conf[db][pass]);
}
catch(PDOException $e)
{
die(Error connecting to the database
Registration is not possible at this moment.);
}

if( isset( $_POST[submit] ) )
{

if( strlen( $_POST[username] ) < 3 || strlen( $_POST[username] ) > 15 )
echo Pick a username between 3 and 15 characters long;

elseif( !ctype_alnum( $_POST[username] ) )
echo Please use only alfanumeric characters as username ( a-Z 0-9 );

elseif( strlen( $_POST[pass1] ) < 3 || strlen( $_POST[pass1] ) > 15 )
echo Pick a password between 3 and 15 characters long;

elseif( strcmp( $_POST[pass1] , $_POST[pass2] ) != 0 )
echo Please use 2x exactley the same passwords;

else
{

$dbh = $db->prepare("SELECT count(*) FROM bg_user WHERE user_id = :userid");
$dbh->bindParam(:userid, $_POST[username], PDO:TongueARAM_STR);

$dbh->execute();

$result = $dbh->fetch();

if( $result[0] != 0 )
echo Username already taken
Please choose another name;

else
{

( $conf[use_encryption] ? $pass = md5( $_POST[pass1] ) : $pass = $_POST[pass1] );

$dbh = $db->prepare("INSERT INTO bg_user (user_id,passwd) VALUES(:userid,:passwd)");

$dbh->bindParam(:userid, $_POST[username], PDO:TongueARAM_STR);
$dbh->bindParam(:passwd, $pass , PDO:TongueARAM_STR);

$dbh->execute();

echo Your account is created.;

}

}
}

else
echo

</pre>
<table>UsernamePasswordPassword (again)</table>
<br><br> ;<br><br

now i have other error:

Notice: Undefined index: server in C:\xampp\htdocs\lc\register.php on line 21

 

Notice: Undefined index: dbase in C:\xampp\htdocs\lc\register.php on line 21

 

Notice: Undefined index: user in C:\xampp\htdocs\lc\register.php on line 25

 

Notice: Undefined index: pass in C:\xampp\htdocs\lc\register.php on line 25

Error connecting to the database

Registration is not possible at this moment.

 

i have my db configuration:

 

// Settings to change

$conf[db][test] = ;

$conf[db][newproject_db_auth] = ;

$conf[db][root] = ;

$conf[db][test] = ;



Messages In This Thread
[No subject] - by Wizatek - 05-02-2012, 09:43 PM
[No subject] - by vavan - 05-06-2012, 01:05 PM
[No subject] - by Blackfire - 05-13-2012, 08:19 AM
[No subject] - by Baikim - 05-18-2012, 11:52 AM
[No subject] - by slowz2seecret - 05-20-2012, 11:12 AM
[No subject] - by Blackfire - 05-20-2012, 11:17 AM
[No subject] - by vavan - 05-20-2012, 11:41 AM
[No subject] - by Ascadia-Network - 05-20-2012, 12:32 PM
[No subject] - by Wizatek - 05-20-2012, 03:08 PM
[No subject] - by slowz2seecret - 05-20-2012, 09:17 PM
[No subject] - by Baikim - 05-20-2012, 10:04 PM
[No subject] - by slowz2seecret - 05-20-2012, 10:21 PM
[No subject] - by Spezzato - 08-18-2012, 03:37 PM
[No subject] - by Wizatek - 08-18-2012, 05:33 PM
[No subject] - by LiQuiD - 10-02-2012, 11:05 AM
[No subject] - by halohalo - 10-24-2012, 02:34 AM
[No subject] - by halohalo - 04-04-2013, 02:50 AM
[No subject] - by fantasymerlin - 01-23-2016, 09:26 AM
[No subject] - by Sutz - 01-25-2016, 01:41 AM
[No subject] - by fantasymerlin - 01-25-2016, 07:49 PM
[No subject] - by Sutz - 01-26-2016, 01:15 AM
[No subject] - by fantasymerlin - 01-26-2016, 07:33 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)