Hi,
I have own site and I have install elgg in subdir elgg/
I have add to register_form.php page in my own site part of code to add user to elgg DB with the same parameters username/password/eamil because I want to register in one place and one time by users. OK I have search google, this group and I have find suggestion that how to add in my register.php part of code:
require_once(dirname(dirname(__FILE__)) . "/elgg/engine/start.php");
global $CONFIG;
$guid = register_user($username, $password, $username, $email);
When I have do this in separate file for example reg.php only with this code all working fine but when I have put in my register_form.php don't work and in log following messages:
------------------------------------
[Mon Aug 16 04:49:49 2010] [error] [client ] WARNING: 2010-08-16 04:49:49 (UTC): "mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO)" in file /var/www/elgg/engine/lib/database.php (line 617)
[Mon Aug 16 04:49:49 2010] [error] [client ] WARNING: 2010-08-16 04:49:49 (UTC): "mysql_real_escape_string(): A link to the server could not be established" in file /var/www/elgg/engine/lib/database.php (line 617)
[Mon Aug 16 04:49:49 2010] [error] [client ] WARNING: 2010-08-16 04:49:49 (UTC): "mysql_real_escape_string(): Access denied for user 'www-data'@'localhost' (using password: NO)" in file /var/www/elgg/engine/lib/database.php (line 617)
[Mon Aug 16 04:49:49 2010] [error] [client ] WARNING: 2010-08-16 04:49:49 (UTC): "mysql_real_escape_string(): A link to the server could not be established" in file /var/www/elgg/engine/lib/database.php (line 617)
[Mon Aug 16 04:49:49 2010] [error] [client ] WARNING: 2010-08-16 04:49:49 (UTC): "mysql_connect(): Access denied for user 'www-data'@'localhost' (using password: NO)" in file /var/www/elgg/engine/lib/database.php (line 51)
[Mon Aug 16 04:49:49 2010] [error] [client ] WARNING: 2010-08-16 04:49:49 (UTC): "fopen(/sess_): failed to open stream: Permission denied" in file /var/www/elgg/engine/lib/sessions.php (line 688)
[Mon Aug 16 04:50:20 2010] [error] [client ] WARNING: 2010-08-16 04:50:20 (UTC): "Cannot use a scalar value as an array" in file /var/www/elgg/engine/lib/database.php (line 51), referer: http://localhost/reg_test.php
[Mon Aug 16 04:50:20 2010] [error] [client ] *** FATAL EXCEPTION *** : exception 'DatabaseException' with message 'Elgg couldn't connect to the database using the given credentials.' in /var/www/elgg/engine/lib/database.php:54\nStack trace:\n#0 /var/www/elgg/engine/lib/database.php(91): establish_db_link('readwrite')\n#1 /var/www/elgg/engine/lib/database.php(154): setup_db_connections()\n#2 /var/www/elgg/engine/lib/database.php(321): get_db_link('read')\n#3 /var/www/elgg/engine/lib/users.php(1026): get_data_row('SELECT e.* from...')\n#4 /var/www/elgg/engine/lib/users.php(1528): get_user_by_username('test')\n#5 /var/www/oc/relgg.php(175): register_user('test', '*****', 'test', 'test@world.com')\n#6 {main}, referer: http://localhost/reg_test.php
[Mon Aug 16 04:50:20 2010] [error] [client ] WARNING: 2010-08-16 04:50:20 (UTC): "Cannot use a scalar value as an array" in file /var/www/elgg/engine/lib/database.php (line 51), referer: http://localhost/reg_test.php
[Mon Aug 16 04:50:20 2010] [error] [client ] PHP Fatal error: Exception thrown without a stack frame in Unknown on line 0, referer: http://localhost/reg_test.php
---------------------------
I don't know where is problem for this reason I will try write register_user function in my part of code to add user in DB elgg below but I am not sure is it all to do add user to DB ?:
$lastGUID=sqlValue("SELECT MAX(guid) guid from elgg_entities",0);
$guid=$lastGUID+1;
$salt=substr(md5(microtime() . rand()), 0, 8);
$pass=md5($password . $salt);
$action_time=microtime(true);
sql("INSERT INTO elgg_entities (guid ,type ,subtype ,owner_guid ,site_guid ,container_guid ,access_id ,time_created,time_updated,last_action,enabl
ed) VALUES ('&1','user','0','0','1','0','2','&2','&3','0','yes')",$guid,$action_time,$action_time);
sql("INSERT INTO `elgg_users_entity` (`guid`,`name`, `username`, `password`,`salt`, `email`) VALUES (
'&1','&2','&3','&4','&5','&6')",$guid,$username,$username, $pass,$salt, $email);
Thanks for any help and suggestion
Regards
info@elgg.org
Security issues should be reported to security@elgg.org!
©2014 the Elgg Foundation
Elgg is a registered trademark of Thematic Networks.
Cover image by RaĆ¼l Utrera is used under Creative Commons license.
Icons by Flaticon and FontAwesome.
coreg plugin :)
- Previous
- 1
- 2
- Next
You must log in to post replies.