I'm trying to implement a external registration form in my website to directly create an account in my PHPBB Forum. I've inserted the login method with ease, but the registry is completly broken.
In my tests, a special code I found is inserting a person with fixed text parameters in PHP, but when I try to parse the information via form, it doesn't work and I made some tests with AJAX to make sure the infos were being sent to the PHP file.
Original Code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
require($phpbb_root_path .'includes/functions_user.php');
$username = request_var('username', '', true);
$password = request_var('password', '', true);
$email = request_var('email', '', true;)
$username = 'testUser';
$password = 'PassWord'; // Dont encrypt the password!
$email = '[email protected]';
// Check for unique username otherwise it will throw an error or might be blank page
$user_row = array(
'username' => $username,
'user_password' => md5($password),
'user_email' => $email,
'group_id' => 2, #Registered users group
'user_timezone' => '1.00',
'user_dst' => 0,
'user_lang' => 'en',
'user_type' => '0',
'user_actkey' => '',
'user_dateformat' => 'd M Y H:i',
'user_style' => 1,
'user_regdate' => time(),
);
$phpbb_user_id = user_add($user_row);
?>
// IP address of the user stored in the Database.
$user_ip = $user->ip;
My Revised Code:
<?php
define('IN_PHPBB', true);
$phpbb_root_path = './';
$phpEx = substr(strrchr(__FILE__, '.'), 1);
include($phpbb_root_path . 'common.' . $phpEx);
// Start session management
$user->session_begin();
$auth->acl($user->data);
$user->setup();
require($phpbb_root_path .'includes/functions_user.php');
$username = request_var('username', '', true);
$password = request_var('password', '', true);
$email = request_var('email', '', true;)
// Check for unique username otherwise it will throw an error or might be blank page
$user_row = array(
'username' => $username,
'user_password' => md5($password),
'user_email' => $email,
'group_id' => 2, #Registered users group
'user_timezone' => '1.00',
'user_dst' => 0,
'user_lang' => 'en',
'user_type' => '0',
'user_actkey' => '',
'user_dateformat' => 'd M Y H:i',
'user_style' => 1,
'user_regdate' => time(),
);
$phpbb_user_id = user_add($user_row);
?>
// IP address of the user stored in the Database.
$user_ip = $user->ip;
My HTML Registration Form:
<div id="page-body">
<script type="text/javascript">
// <![CDATA[
/**
* Change language
*/
function change_language(lang_iso)
{
document.forms['register'].change_lang.value = lang_iso;
document.forms['register'].submit.click();
}
// ]]>
</script>
<form action="../../forum/ucp.php?mode=register" method="POST">
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<strong><span style="color: #ff3399;"><span style="font-family: Arial;"><span style="font-size: 16px;">OnlineWinxClub.com</span></span></span></strong><br><span style="font-size: 13px;"><span style="font-family: Arial;"><span style="color: #000000;">Account Registration</span></span></span>
<dl>
<dt><span style="color: #425067;"><span style="font-size: 13px;"><strong><span style="font-family: Arial;">Username:</span></strong></span></span><br><span style="font-size: 13px;"><span style="font-family: Arial;">Try not to use your real name!</span></span></dt>
<dd><input type="text" tabindex="1" name="username" id="username" size="45" value="" class="inputbox autowidth" title="Username"></dd>
</dl>
<dl>
<dt><span style="color: #425067;"><span style="font-size: 13px;"><strong><span style="font-family: Arial;">E-mail Address:</span></strong></span></dt>
<dd><input type="text" tabindex="2" name="email" id="email" size="45" maxlength="150" value="" class="inputbox autowidth" title="E-mail address"></dd>
</dl>
<dl>
<dt><span style="color: #425067;"><span style="font-size: 13px;"><strong><span style="font-family: Arial;">Confirm your e-mail address:</span></strong></span></span></dt>
<dd><input type="text" tabindex="3" name="email_confirm" id="email_confirm" size="45" maxlength="150" value="" class="inputbox autowidth" title="Confirm e-mail address"></dd>
</dl>
<dl>
<dt><span style="color: #425067;"><span style="font-size: 13px;"><strong><span style="font-family: Arial;">Password:</span></strong></span></span><br><span style="font-size: 13px;"><span style="font-family: Arial;"><span style="color: #000000;">Must be between 6 and 100 characters.</span></span></dt>
<dd><input type="password" tabindex="4" name="new_password" id="new_password" size="45" value="" class="inputbox autowidth" title="New password"></dd>
</dl>
<dl>
<dt><span style="color: #425067;"><span style="font-size: 13px;"><strong><span style="font-family: Arial;">Confirm Password:</span></strong></span></dt>
<dd><input type="password" tabindex="5" name="password_confirm" id="password_confirm" size="45" value="" class="inputbox autowidth" title="Confirm password"></dd>
</dl>
</fieldset>
<span class="corners-bottom"><span></span></span></div>
</div>
<div class="panel">
<div class="inner"><span class="corners-top"><span></span></span>
<fieldset class="submit-buttons">
<input type="hidden" name="agreed" value="true">
<input type="hidden" name="change_lang" value="0">
<input type="reset" value="Reset" name="reset" class="button2">
<input type="submit" tabindex="9" name="submit" id="submit" value="Submit" class="button1 default-submit-action">
<input type="hidden" name="creation_time" value="1618066803">
<input type="hidden" name="form_token" value="77214643d17e0a3345b1136be2c64de4a4d6b632">
</fieldset>
<span class="corners-bottom"><span></span></span></div>
</div>
</form>
</div>