Go Back   vb.org Archive > vBulletin 3 Discussion > vB3 General Discussions
  #1  
Old 05-13-2006, 10:38 PM
Connector Connector is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default custom page Questions Help. !?

Hello ,

I was trying to creat a custom Register Page outside the vB And i will use the Custom Page writing in this page but for some reson it dont work with me .. could someone please give me example code working ?

PHP Code:
<?php
    
# Add a user to vBulletin (offline)
        
    
function qpc_post($varname)
    {
        return 
trim(stripslashes((get_magic_quotes_gpc()) ? $_POST[$varname] : addslashes($_POST[$varname])));
    }

    
define('THIS_SCRIPT''bb_add_user.php');
    require_once(
'./global.php');
    require_once(
'./includes/class_dm.php');
    require_once(
'./includes/class_dm_user.php');

    
$userdm = new vB_DataManager_User($vbulletinERRTYPE_ARRAY);
    
    
$userdm->set('username'qpc_post('username'));
    
$userdm->set('email'qpc_post('email'));
    
$userdm->set('password'qpc_post('password'));
    
$userdm->set('usergroupid'2);
    
$userdm->set('ipaddress'qpc_post('ipaddress'));
    
$userdm->set('referrerid'qpc_post('referrername'));
    
$userdm->set('timezoneoffset'qpc_post('timezoneoffset'));
    
$userdm->set_bitfield('options''adminemail'intval(qpc_post('adminemail')));
    
$userdm->set_bitfield('options''showemail'intval(qpc_post('showemail')));
    
    
$dst_setting intval(qpc_post('dst'));
    switch (
$dst_setting)
    {
        case 
0:
        case 
1:
            
$userdm->set_bitfield('options''dstonoff'$dst_setting);
            break;
        case 
2:
            
$userdm->set_bitfield('options''dstauto'1);
            break;
    }
    
    
#If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using
    
if (count($userdm->errors)) {
        for(
$i=0$i<count($userdm->errors); $i++) {
            print 
"ERROR{$i}:{$userdm->errors[$i]}\n";
        }
    } else {
        
# If everything is OK
        
$newuserid $userdm->save();
        print 
"vbuserid:$newuserid\n";
    }
    

?>
Thankyou
Reply With Quote
  #2  
Old 05-14-2006, 09:01 AM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

What part doesn't work? Do you get any errors from $userdm->errors ?

Thanks,
Alan.
Reply With Quote
  #3  
Old 05-14-2006, 10:44 AM
Connector Connector is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello

i'm getting this error

Quote:
ERROR0:Please complete the required field "Username". ERROR1:Please complete the required field "Email".

I hope There is some way to fix this error ..

Thanks
Reply With Quote
  #4  
Old 05-14-2006, 10:49 AM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Looks like your form isn't passing the username and e-mail paramaters to your script.

What does your form look like? (the HTML)

Thanks,
Alan.
Reply With Quote
  #5  
Old 05-14-2006, 11:14 AM
Connector Connector is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello

Thanks for the fast Reply

I have copy the html code in the register template and put it in the new custom one just to make sure it willl work or not but seem like there is a few error

here is a complate code both html and php

HTML Code:
$stylevar[htmldoctype]
<html dir="$stylevar[textdirection]" lang="$stylevar[languagecode]">
<head>
$headinclude
<title>$vboptions[bbtitle] - <if condition="$show['coppa']">$vbphrase[coppa] </if>$vbphrase[registration]</title>
</head>
<body>

$header

<br />

<table cellpadding="2" cellspacing="0" border="0" width="100%" align="center">
<tr>
	<td>
		
		<if condition="$show['coppa']">
			$vbphrase[until_receive_signed_form]
		</if>
	</td>
</tr>
<if condition="$show['errors']">
	<tr>
		<td><strong>$vbphrase[errors_occurred_during_registration]:</strong>
			<ul>
			$errorlist
			</ul>
		</td>
	</tr>
</if>
</table>

<br />

<script type="text/javascript" src="clientscript/vbulletin_md5.js"></script>
<script type="text/javascript">
function verify_passwords(password1, password2)
{
	// do various checks, this will save people noticing mistakes on next page
	if (password1.value == '' || password2.value == '')
	{
		alert('$vbphrase[fill_out_both_password_fields]');
		return false;
	}
	else if (password1.value != password2.value)
	{
		alert('$vbphrase[entered_passwords_do_not_match]');
		return false;
	}
	else
	{
		<if condition="$show['coppa']">
		pass_copy = password1.value;
		passconfirm_copy = password2.value;
		</if>

		var junk_output;
		
		md5hash(password1, document.forms.register.password_md5, junk_output, $show[nopasswordempty]);
		md5hash(password2, document.forms.register.passwordconfirm_md5, junk_output, $show[nopasswordempty]);
		
		<if condition="$show['coppa']">
		document.forms.register.password.value = pass_copy;
		document.forms.register.passwordconfirm.value = passconfirm_copy;
		</if>
		
		return true;
	}
	return false;
}
</script>

<form action="register.php" name="register" method="post" onsubmit="return verify_passwords(password, passwordconfirm);">
<input type="hidden" name="s" value="$session[sessionhash]" />
<if condition="$vboptions['invites_enabled']">
	<input type="hidden" name="invite" value="$invite" />
</if>
<input type="hidden" name="do" value="addmember" />
<input type="hidden" name="url" value="$url" />
<input type="hidden" name="agree" value="$agree" />
<input type="hidden" name="password_md5" />
<input type="hidden" name="passwordconfirm_md5" />
<if condition="!$show['birthdays']">
	<input type="hidden" name="day" value="$day" />
	<input type="hidden" name="month" value="$month" />
	<input type="hidden" name="year" value="$year" />
</if>
<if condition="$show['coppa']">
	<input type="hidden" name="coppauser" value="1" />
</if>

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
	<td class="tcat"><phrase 1="$vboptions[bbtitle]">$vbphrase[register_at_x]</phrase></td>
</tr>
<tr>
	<td class="panelsurround" align="center">
	<div class="panel">
		<div style="width:$stylevar[formwidth]" align="$stylevar[left]">
		
			<div class="smallfont" style="margin-bottom:$stylevar[formspacer]px">
				<phrase 1="$vboptions[bbtitle]">$vbphrase[to_post_must_first_register]</phrase>
			</div>
			
			<div class="smallfont" style="margin-bottom:$stylevar[formspacer]px">
				<strong>$vbphrase[username]</strong>:<br />
				<input type="text" class="bginput" name="username" size="50" maxlength="$vboptions[maxuserlength]" value="$username" />
			</div>
			
			<fieldset class="fieldset">
				<legend>$vbphrase[password]</legend>
				<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" width="400">
				<tr>
					<td colspan="2">$vbphrase[enter_password_for_account]</td>
				</tr>
				<tr>
					<td>
						$vbphrase[password]:<br />
						<input type="password" class="bginput" name="password" size="25" maxlength="15" value="$password" />
					</td>
					<td>
						$vbphrase[confirm_password]:<br />
						<input type="password" class="bginput" name="passwordconfirm" size="25" maxlength="15" value="$passwordconfirm" />
					</td>
				</tr>
				</table>
			</fieldset>
			
			<fieldset class="fieldset">
				<legend>$vbphrase[email_address]</legend>
				<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" width="400">
				<tr>
					<td colspan="2">$vbphrase[enter_valid_email_address]</td>
				</tr>
				<tr>
					<td>
						$vbphrase[email_address]:<br />
						<input type="text" class="bginput" name="email" size="25" maxlength="50" value="$email" dir="ltr" />
					</td>
					<td>
						$vbphrase[confirm_email_address]:<br />
						<input type="text" class="bginput" name="emailconfirm" size="25" maxlength="50" value="$emailconfirm" dir="ltr" />
					</td>
				</tr>
				<if condition="$show['coppa']">
				<tr>
					<td>$vbphrase[if_under_13_provide_parent]</td>
				</tr>
				<tr>
					<td>
						$vbphrase[parent_guardian_email]:<br />
						<input type="text" class="bginput" name="parentemail" size="25" maxlength="50" value="$parentemail" dir="ltr" />
					</td>
				</tr>
				</if>
				</table>
			</fieldset>
			
			<if condition="$show['regimagecheck']">
			<fieldset class="fieldset">
				<legend>$vbphrase[image_verification]</legend>
				<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0">
				<tr>
					<td>
						$vbphrase[enter_text_image_right]
					</td>
					<td rowspan="2"><img src="image.php?$session[sessionurl]type=regcheck&amp;imagehash=$imagehash" alt="$vbphrase[registration_image]" width="201" height="61" border="0" /></td>
				</tr>
				<tr>
					<td><input type="text" class="bginput" name="imagestamp" size="50" maxlength="6" /><input type="hidden" name="imagehash" value="$imagehash" /></td>
				</tr>
				</table>
			</fieldset>
			</if>
			
		</div>
	</div>
	</td>
</tr>
</table>
<br />

<if condition="$show['customfields_profile']">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
	<td class="thead">$vbphrase[additional_required_information_profile]</td>
</tr>
<tr>
	<td class="panelsurround" align="center">
	<div class="panel">
		<div style="width:$stylevar[formwidth]" align="$stylevar[left]">
		
			$customfields_profile
			
			<if condition="$show['birthday']">$birthdayfields</if>
		
		</div>
	</div>
	</td>
</tr>
</table>
<br />
</if>

<if condition="$show['customfields_option']">
<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
	<td class="thead">$vbphrase[additional_required_information_option]</td>
</tr>
<tr>
	<td class="panelsurround" align="center">
	<div class="panel">
		<div style="width:$stylevar[formwidth]" align="$stylevar[left]">
		
			$customfields_option
		
		</div>
	</div>
	</td>
</tr>
</table>
<br />
</if>

<table class="tborder" cellpadding="$stylevar[cellpadding]" cellspacing="$stylevar[cellspacing]" border="0" width="100%" align="center">
<tr>
	<td class="thead">$vbphrase[additional_information]</td>
</tr>
<tr>
	<td class="panelsurround" align="center">
	<div class="panel">
		<div style="width:$stylevar[formwidth]" align="$stylevar[left]">
<if condition="$referrername">
<input type="hidden" name="referrername" value="$referrername" />
<else />

			<if condition="$show['referrer']">
			<fieldset class="fieldset">
				<legend>$vbphrase[referrer]</legend>
				<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" width="100%">
				<tr>
					<td><phrase 1="$vboptions[bbtitle]">$vbphrase[if_referred_enter_name]</phrase></td>
				</tr>
				<tr>
					<td>
						$vbphrase[referrer]:<br />
						<input type="text" class="bginput" name="referrername" value="$referrername" size="50" maxlength="250" />
					</td>
				</tr>
				</table>
			</fieldset>
			</if>
</if>
		
			$timezoneoptions
			
			<fieldset class="fieldset">
				<legend>$vbphrase[receive_email]</legend>
				<table cellpadding="0" cellspacing="$stylevar[formspacer]" border="0" width="100%">
				<tr>
					<td>
						$vbphrase[administrators_may_send_email]
					</td>
				</tr>
				<tr>
					<td><label for="cb_adminemail"><input type="checkbox" name="options[adminemail]" value="1" id="cb_adminemail" $checkedoff[adminemail] />$vbphrase[receive_email_from_bulletin_board_staff]</label></td>
				</tr>
				<if condition="$show['email']">
				<tr>
					<td>$vbphrase[allow_members_send_you_email]</td>
				</tr>
				<tr>
					<td><label for="cb_showemail"><input type="checkbox" name="options[showemail]" value="1" id="cb_showemail" $checkedoff[showemail] />$vbphrase[receive_email_from_other_members]</label></td>
				</tr>
				</if>
				</table>
			</fieldset>

			
			$customfields_other
		
		</div>
	</div>
	
	<div style="margin-top:$stylevar[cellpadding]px">
		<input type="submit" class="button" value="$vbphrase[complete_registration]" accesskey="s" />
		<input type="reset" class="button" name="Reset" value="$vbphrase[reset_fields]" />
	</div>
	</td>
</tr>
</table>

</form>

$footer

</body>
</html>

And The PHP code

PHP Code:
<?php 

// ######################## SET PHP ENVIRONMENT ########################### 
error_reporting(E_ALL & ~E_NOTICE); 

// ##################### DEFINE IMPORTANT CONSTANTS ####################### 
// change the line below to the actual filename without ".php" extention. 
// the reason for using actual filename without extention as a value of this constant is to ensure uniqueness of the value 

throughout every PHP file of any given vBulletin installation

define('THIS_SCRIPT''test');  

// #################### PRE-CACHE TEMPLATES AND DATA ###################### 
// get special phrase groups 
$phrasegroups = array(); 

// get special data templates from the datastore 
$specialtemplates = array(); 

// pre-cache templates used by all actions 
$globaltemplates = array( 
        
// change the lines below to the list of actual templates used in the script 
        
'custom_register'
); 

// pre-cache templates used by specific actions 
$actiontemplates = array(); 

// ########################## REQUIRE BACK-END ############################ 
chdir('/home/connet31/public_html/forums'); 
require_once(
'./global.php');

// #################### HARD CODE JAVASCRIPT PATHS ######################## 
$headinclude str_replace('clientscript'$vbulletin->options['bburl'] . '/clientscript'$headinclude); 

// ######################################################################## 
// ######################### START MAIN SCRIPT ############################ 
// ########################################################################
    # Add a user to vBulletin (offline) 
         
    
function qpc_post($varname
    { 
        return 
trim(stripslashes((get_magic_quotes_gpc()) ? $_POST[$varname] : addslashes($_POST[$varname]))); 
    } 

    
define('THIS_SCRIPT''bb_add_user.php'); 
    require_once(
'./global.php'); 
    require_once(
'./includes/class_dm.php'); 
    require_once(
'./includes/class_dm_user.php'); 

    
$userdm = new vB_DataManager_User($vbulletinERRTYPE_ARRAY); 
     
    
$userdm->set('username'qpc_post('username')); 
    
$userdm->set('email'qpc_post('email')); 
    
$userdm->set('password'qpc_post('password')); 
    
$userdm->set('usergroupid'2); 
    
$userdm->set('ipaddress'qpc_post('ipaddress')); 
    
$userdm->set('referrerid'qpc_post('referrername')); 
    
$userdm->set('timezoneoffset'qpc_post('timezoneoffset')); 
    
$userdm->set_bitfield('options''adminemail'intval(qpc_post('adminemail'))); 
    
$userdm->set_bitfield('options''showemail'intval(qpc_post('showemail'))); 
     
    
$dst_setting intval(qpc_post('dst')); 
    switch (
$dst_setting
    { 
        case 
0
        case 
1
            
$userdm->set_bitfield('options''dstonoff'$dst_setting); 
            break; 
        case 
2
            
$userdm->set_bitfield('options''dstauto'1); 
            break; 
    } 
     
    
#If there are errors (eMail not set, eMail banned, Username taken, etc.) you can check for errors using 
    
if (count($userdm->errors)) { 
        for(
$i=0$i<count($userdm->errors); $i++) { 
            print 
"ERROR{$i}:{$userdm->errors[$i]}\n"
        } 
    } else { 
        
# If everything is OK 
        
$newuserid $userdm->save(); 
        print 
"vbuserid:$newuserid\n"
    }

$navbits = array();  
// change the line below to contain whatever you want to show in the navbar (title of your custom page) 
$navbits[$parent] = 'Test Page'

$navbits construct_navbits($navbits); 
eval(
'$navbar = "' fetch_template('navbar') . '";'); 

// change the line below to contain the name of the actual main output template used in your script 
eval('print_output("' fetch_template('custom_register') . '");'); 

?>
i'm not sure what wrong i'm doing .. but could you please take a l ook at the code and if you have some time to give me a example working code .. ?

here i will attach for you a screenshot how the error look like..

Thanks
Attached Images
File Type: jpg registererror.jpg (205.9 KB, 0 views)
Reply With Quote
  #6  
Old 05-14-2006, 11:22 AM
Alan @ CIT Alan @ CIT is offline
 
Join Date: Nov 2004
Location: South UK
Posts: 625
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

First problems that springs to mind is that your form is sending to register.php, instead of your custom PHP script

Code:
<form action="register.php" ...
Try changing that first off, and we'll go from there
Reply With Quote
  #7  
Old 05-15-2006, 09:04 AM
Connector Connector is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Hello

I have change that .. know i'm able to Creat a username from this page ..but that error still showing ..

1- After i regisiter a username there is no email sent .. and the username go direct to Register User .. without they confirm their account ..
2- i have a few Custom Profile Field .. is there any way i can add them in this custom register page ?
Reply With Quote
  #8  
Old 05-17-2006, 05:42 PM
Connector Connector is offline
 
Join Date: Dec 2005
Location: Spain
Posts: 97
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bmup.!

bmup.!
Reply With Quote
  #9  
Old 09-20-2006, 05:31 PM
BWilliams BWilliams is offline
 
Join Date: Dec 2005
Location: Southern California
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

Did you ever figure this out? I am looking at creating a "custom" registration page and am clueless were to even start.
Reply With Quote
  #10  
Old 09-26-2006, 06:59 PM
BWilliams BWilliams is offline
 
Join Date: Dec 2005
Location: Southern California
Posts: 29
Благодарил(а): 0 раз(а)
Поблагодарили: 0 раз(а) в 0 сообщениях
Default

bump
Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT. The time now is 04:54 PM.


Powered by vBulletin® Version 3.8.12 by vBS
Copyright ©2000 - 2025, vBulletin Solutions Inc.
X vBulletin 3.8.12 by vBS Debug Information
  • Page Generation 0.04703 seconds
  • Memory Usage 2,382KB
  • Queries Executed 12 (?)
More Information
Template Usage:
  • (1)SHOWTHREAD
  • (1)ad_footer_end
  • (1)ad_footer_start
  • (1)ad_header_end
  • (1)ad_header_logo
  • (1)ad_navbar_below
  • (1)ad_showthread_beforeqr
  • (1)ad_showthread_firstpost
  • (1)ad_showthread_firstpost_sig
  • (1)ad_showthread_firstpost_start
  • (1)bbcode_code
  • (1)bbcode_html
  • (2)bbcode_php
  • (1)bbcode_quote
  • (1)footer
  • (1)forumjump
  • (1)forumrules
  • (1)gobutton
  • (1)header
  • (1)headinclude
  • (1)navbar
  • (3)navbar_link
  • (120)option
  • (10)post_thanks_box
  • (10)post_thanks_button
  • (1)post_thanks_javascript
  • (1)post_thanks_navbar_search
  • (10)post_thanks_postbit_info
  • (10)postbit
  • (1)postbit_attachment
  • (10)postbit_onlinestatus
  • (10)postbit_wrapper
  • (1)spacer_close
  • (1)spacer_open
  • (1)tagbit_wrapper 

Phrase Groups Available:
  • global
  • inlinemod
  • postbit
  • posting
  • reputationlevel
  • showthread
Included Files:
  • ./showthread.php
  • ./global.php
  • ./includes/init.php
  • ./includes/class_core.php
  • ./includes/config.php
  • ./includes/functions.php
  • ./includes/class_hook.php
  • ./includes/modsystem_functions.php
  • ./includes/functions_bigthree.php
  • ./includes/class_postbit.php
  • ./includes/class_bbcode.php
  • ./includes/functions_reputation.php
  • ./includes/functions_post_thanks.php 

Hooks Called:
  • init_startup
  • init_startup_session_setup_start
  • init_startup_session_setup_complete
  • cache_permissions
  • fetch_threadinfo_query
  • fetch_threadinfo
  • fetch_foruminfo
  • style_fetch
  • cache_templates
  • global_start
  • parse_templates
  • global_setup_complete
  • showthread_start
  • showthread_getinfo
  • forumjump
  • showthread_post_start
  • showthread_query_postids
  • showthread_query
  • bbcode_fetch_tags
  • bbcode_create
  • showthread_postbit_create
  • postbit_factory
  • postbit_display_start
  • post_thanks_function_post_thanks_off_start
  • post_thanks_function_post_thanks_off_end
  • post_thanks_function_fetch_thanks_start
  • post_thanks_function_fetch_thanks_end
  • post_thanks_function_thanked_already_start
  • post_thanks_function_thanked_already_end
  • fetch_musername
  • postbit_imicons
  • bbcode_parse_start
  • bbcode_parse_complete_precache
  • bbcode_parse_complete
  • postbit_display_complete
  • post_thanks_function_can_thank_this_post_start
  • postbit_attachment
  • tag_fetchbit_complete
  • forumrules
  • navbits
  • navbits_complete
  • showthread_complete