Inserting a new user into MediaWiki database

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
Josh1billion
Forum Contributor
Posts: 316
Joined: Tue Sep 11, 2007 3:25 pm

Inserting a new user into MediaWiki database

Post by Josh1billion »

I have a new Wiki, and I'm trying to make it so that the only way to create an account is from another page on my site, much like I did with my forums.

There must be something I'm missing, though. Has anyone worked with MediaWiki before? The problem I'm having here is that when I try to log in with my new user, it says no user by that username exists (even though I can see that it clearly does, inside of the database).

Here's my new user creation code, in two queries (first query creates the user; second query fixes the user's password since the password is generated based partially on the user_id, which isn't known until after the user is inserted into the database):

Code: Select all

$result = mysql_query("INSERT INTO `wiki_user` (`user_name`, `user_password`) VALUES ('$user_name', 'asdf')");
		if (!$result)
			die("Error in char_CreateWikiAccount: could not create new account because: " . mysql_error());
			
		$user_id = mysql_insert_id();
		$result = mysql_query("UPDATE `wiki_user` SET `user_password` = MD5(CONCAT(user_id, '-', MD5('$raw_password'))) WHERE `user_id` = '$user_id';");
		if (!$result)
			die("Error in char_CreateWikiAccount: could not update new password because: " . mysql_error());

After looking at the user database, it looks like these are the only important fields of the user table:

user_id, user_name, user_password, user_options, user_token

The other fields are either empty or null, or are basically registration times and last login times. The only field I'm really sensing could be the problem here is user_token, but after googling and googling, and searching through the MediaWiki source code, I haven't found out much about what it is or what it does. It appears to be something dealing with cookies, something I'll have to take a closer look at later, but I don't see how it could be causing the current problem (username not found) unless the error message is actually reporting an incorrect error.

Hopefully, someone here has worked with MediaWiki modifications in the past and has an idea on what exactly I'm doing wrong here.

Edit: I have also posted this here: http://www.mwusers.com/forums/showthrea ... #post20477
User avatar
Josh1billion
Forum Contributor
Posts: 316
Joined: Tue Sep 11, 2007 3:25 pm

Post by Josh1billion »

Nevermind, I have decided to use a phpBB MediaWiki extension (Auth_phpBB) instead, so now my users just log in with their forum accounts (which happen to be the same as their game accounts).
Post Reply