0

I want insert some record via external PHP script in phpfox framework table phpfox_user

Applied reference.The registration of user in table phpfox_user accessing php library functions from outside of phpfox was working fine previously.

$iId = Phpfox::getService('user.process')->add($aVals);

// if fine, $iId is ID of user in `phpfox_user` table, otherwise $iId = false.


<?php
echo "This is the beginning."; 
include('auth.php');
include('config1.php');
define('PHPFOX', true); 
define('PHPFOX_DS', DIRECTORY_SEPARATOR); 
define('PHPFOX_DIR', dirname(__FILE__) . PHPFOX_DS); 
define('PHPFOX_START_TIME', array_sum(explode(' ', microtime()))); 
require_once(PHPFOX_DIR . 'include' . PHPFOX_DS . 'init.inc.php'); 


    $aVals = array(
'full_name' => 'Naveen Kumart',
'email' => 'testrew@abc.com',
'password' => 'Alobha1',
'gender' => 1, // 1: male 2: female
);

if (Phpfox::getParam('core.registration_enable_dob')) {
// if birthday on registration is required, assign birthday parameters here. I give a sample 1/1/1988
$aVals['month'] = '1'; 
$aVals['day'] = '1';
$aVals['year'] = '1988';


}

$iId = Phpfox::getService('user.process')->add($aVals);

// if fine, $iId is ID of user in `phpfox_user` table, otherwise $iId = false.
if ($iId) {
echo $iId;
} else {
echo 'false';
}

echo "This is the end"; 


?>
Saveen
  • 4,120
  • 14
  • 38
  • 41

1 Answers1

0

If you are using phpFox V4, you replace:

<?php
echo "This is the beginning."; 
include('auth.php');
include('config1.php');
define('PHPFOX', true); 
define('PHPFOX_DS', DIRECTORY_SEPARATOR); 
define('PHPFOX_DIR', dirname(__FILE__) . PHPFOX_DS); 
define('PHPFOX_START_TIME', array_sum(explode(' ', microtime()))); 
require_once(PHPFOX_DIR . 'include' . PHPFOX_DS . 'init.inc.php'); 

By

define('PHPFOX_PARENT_DIR', __DIR__ . DIRECTORY_SEPARATOR);
define('PHPFOX_NO_RUN', true);
require('./PF.Base/start.php');

Update PHPFOX_PARENT_DIR if your file is not the same dir with index.php

Trung Ngon
  • 51
  • 1