1 (edited by zentropy 2008-01-09 22:54)

Topic: Trying to inject accounts from a website into punbb. Howto?

I tried the following. When a user registers at out website i wanted that the registered information got also injected into the punbb database so that the user didn't have to register seperately later on the forums. But this didn't work, no user got added to the user table and neither was i able to login after registration. What am i doing wrong?

here's the code:

               
                $group_id = "4";
    $user_regdate = strtotime ("now"); // Unix Timestamp
    $user_password=pun_hash($user->Password);
    $username=$user->Username;
    $user_email=$user->EmailAddress;
    $user_lang = "english";
    $user_timezone = "0";
    
    $query_ft = "INSERT INTO punbb_users (group_id, registered, username, password, email, language, timezone) values ('$group_id','$user_regdate','$username','$user_password','$user_email','$user_lang','$user_timezone')";   
    mysql_query($query_ft, $conn) or die (mysql_error());

Re: Trying to inject accounts from a website into punbb. Howto?

Also for this to work, does e-mail verification need to be turned off?

Re: Trying to inject accounts from a website into punbb. Howto?

Email verification is irrelevant with your example
"english" should be "English"
That's the only thing I notice, are the tables in the same database?

4 (edited by zentropy 2008-01-09 23:39)

Re: Trying to inject accounts from a website into punbb. Howto?

No the tables are not in the same database but i opened up a connection to the punBB database before the above mentioned code.

It looks like this:

$dbhost = 'localhost';
$dbuser = 'username';
$dbpasswd = 'password';
$dbname = 'punbbdatabasename';

after those variables are set the following code is included:

$conn = mysql_connect($dbhost, $dbuser, $dbpasswd) or die ('Error connecting to mysql');
mysql_select_db("$dbname",$conn) or die ("could not open db".mysql_error());

Re: Trying to inject accounts from a website into punbb. Howto?

I'll need to see your complete code to tell anything more

6 (edited by zentropy 2008-01-10 00:04)

Re: Trying to inject accounts from a website into punbb. Howto?

This is basically it:

    
$dbhost = 'localhost';
$dbuser = 'username';
$dbpasswd = 'password';
$dbname = 'punbbdatabasename';

$conn = mysql_connect($dbhost, $dbuser, $dbpasswd) or die ('Error connecting to mysql');
mysql_select_db("$dbname",$conn) or die ("could not open db".mysql_error());


         $group_id = "4";
    $user_regdate = strtotime ("now"); // Unix Timestamp
    $user_password=pun_hash($user->Password);
    $username=$user->Username;
    $user_email=$user->EmailAddress;
    $user_lang = "english";
    $user_timezone = "0";
    
    $query_ft = "INSERT INTO punbb_users (group_id, registered, username, password, email, language, timezone) values ('$group_id','$user_regdate','$username','$user_password','$user_email','$user_lang','$user_timezone')";   
    mysql_query($query_ft, $conn) or die (mysql_error());

Re: Trying to inject accounts from a website into punbb. Howto?

And the script runs fine without an error? But no row is inserted in the database?

Re: Trying to inject accounts from a website into punbb. Howto?

Smartys wrote:

And the script runs fine without an error? But no row is inserted in the database?

I get no errors, but no row is inserted, double checked the database and the user table.

Re: Trying to inject accounts from a website into punbb. Howto?

I don't know what to tell you, the problem has to be with the script if no row is being inserted.
Try echoing out the SQL query and then running it by hand. If it works, then you know the problem is not the query but with the connection. If it doesn't, then you'll be able to debug what's wrong with the query.

10 (edited by zentropy 2008-01-10 00:37)

Re: Trying to inject accounts from a website into punbb. Howto?

I noticed that config.php in the punbb root directory has a few more variables set there. Is it possible i set too few variables to setup a proper connection to punbb's database?

Re: Trying to inject accounts from a website into punbb. Howto?

No, your file looks fine from that end. The issue could always be a parse error if display_errors is off on your server: you wouldn't be able to echo the SQL in that case though.

12 (edited by zentropy 2008-01-10 15:32)

Re: Trying to inject accounts from a website into punbb. Howto?

Ok i found an error, i forgot to include punbb/includes/functions.php  so the pun_hash() function wasn't able to be called. But now it still doesn't work. Have i forgotten to import more files to make this work? Like common.php for example?

This is the code i have now with functions.php included:

 
$dbhost = 'localhost';
$dbuser = 'username';
$dbpasswd = 'password';
$dbname = 'punbbdatabasename';

$conn = mysql_connect($dbhost, $dbuser, $dbpasswd) or die ('Error connecting to mysql');
mysql_select_db("$dbname",$conn) or die ("could not open db".mysql_error());

include "punbb/includes/functions.php"; 


    $group_id = "4";
    $user_regdate = strtotime ("now"); // Unix Timestamp
    $user_password=pun_hash($user->Password);
    $username=$user->Username;
    $user_email=$user->EmailAddress;
    $user_lang = "english";
    $user_timezone = "0";
    
    $query_ft = "INSERT INTO punbb_users (group_id, registered, username, password, email, language, timezone) values ('$group_id','$user_regdate','$username','$user_password','$user_email','$user_lang','$user_timezone')";   
    mysql_query($query_ft, $conn) or die (mysql_error());

And that gives the following errors:

Warning: include(punbb/includes/functions.php) [function.include]: failed to open stream: No such file or directory in /somepath/register.php on line 1222

Warning: include() [function.include]: Failed opening 'punbb/includes/functions.php' for inclusion (include_path='.:/usr/local/lib/php5') in /somepath/register.php on line 1222

Fatal error: Call to undefined function pun_hash() in /somepath/register.php on line 1226

13 (edited by zentropy 2008-01-12 16:44)

Re: Trying to inject accounts from a website into punbb. Howto?

Ok the code works now. I made a typo. The path to the functions.php file is not punbb/includes but punbb/include .
So far so good. Thanks for your help Smartys. Really appreciate it.

14

Re: Trying to inject accounts from a website into punbb. Howto?

I'm a bit lost here. Please, tell me where that piece of code goes.

Re: Trying to inject accounts from a website into punbb. Howto?

Dav wrote:

I'm a bit lost here. Please, tell me where that piece of code goes.

That appears to go (modified to suit your needs) into the registration form for your site (only if you have one other than PunBB's, of course).

Looking for a certain modification for your forum? Please take a look here before posting.

16

Re: Trying to inject accounts from a website into punbb. Howto?

I want to integrate WP and Punbb. I thought that this piece of code helps me. But can you help me to understand where that code goes.

17

Re: Trying to inject accounts from a website into punbb. Howto?

Hello All,
   I am new to this forum..and also I am newbie.

This forum software really rocks and your supports are extremely good.

i am alredy running a website, with registration form.

according this post, i did to include username,pass and email into forum database.

unfortunately it is showing error

"There was a problem while processing your request. Please try again and if this problem persists, contact the administrator "

my code is

$conn = mysql_connect($dbhost, $dbuser, $dbpasswd) or die ('Error connecting to mysql');
mysql_select_db("$dbname",$conn) or die ("could not open db".mysql_error());

              $query_ft = "INSERT INTO foo_users (username, password, email) values ('".$username."', '".md5($pass)."', '".$email."')";
                mysql_query($query_ft, $conn) or die (mysql_error());    

18

Re: Trying to inject accounts from a website into punbb. Howto?

Study out the script from this post, it should help you.