Welcome to Geeklog, Anonymous Thursday, December 26 2024 @ 05:10 pm EST
Geeklog Forums
Trying to manipulate new usernames
Status: offline
EKwant
Forum User
Junior
Registered: 09/29/02
Posts: 19
Hello all,
I'm trying to manipulate the createuser function in users.php (GL 1.3.6) so that when I have a new user fill out the registration form, they input their first name, last name, and email, instead of just a single username. The registration form I have modified already and added these forms, with the variable names firstname, lastname, and email.
I'm having trouble getting the users.php script to "merge" the first name and last name together, with a "_" in between them. Here is what I have so far, that isn't working: 331 function createuser($firstname,$lastname,$email)
332 {
333 global $_TABLES, $LANG04, $_CONF;
334
335 $username = $firstname . '_' . $lastname;
336 $ucount = DB_count($_TABLES['users'],'username',$username);
337 $ecount = DB_count($_TABLES['users'],'email',$email);
338
339 if ($ucount == 0 AND $ecount == 0) {
340 if (COM_isEmail($email)) {
341 $regdate = strftime('%Y-%m-%d %H:%M:$S',time());
342 DB_save($_TABLES['users'],'username,email,regdate',"'$username','$email','$regdate'"
343 $uid = DB_getItem($_TABLES['users'],'uid',"username = '$username'"
What it does when I enter a new registration, is only uses the firstname variable appended with the "_". It ignores the lastname variable.
My PHP experience is *very* fresh, so any solutions would be much appreciated!
11
8
Quote
Anonymous
Anonymous
So if I understand correctly you are wanting to replace the short username with the long fullname and not give the user the option of entering a short username. On that assumption, here is what I would do. First it appears to me your code would work. I would first verify that you are getting the $firstname and $lastname variables passed correctly. Add this line immediately before the call to your createuser function:
COM_errorLog("firstname = $firstname <> lastname = $lastname",1);
And see what is in the error log. I bet one or both of them ain't there.
G-Wiz
10
9
Quote
Status: offline
EKwant
Forum User
Junior
Registered: 09/29/02
Posts: 19
Thanks for the help!
You were correct. The lastname wasn't getting passed properly due to what seemed to be a stray carriage return located just after the first quotation mark in my registration form where the statement name="lastname" was.
I didn't notice it until I looked at the webpage source in a text editor. /
Thanks again G-Wiz. That errorlog statement you suggested might come in handy in the future.
9
8
Quote
All times are EST. The time is now 05:10 pm.
- Normal Topic
- Sticky Topic
- Locked Topic
- New Post
- Sticky Topic W/ New Post
- Locked Topic W/ New Post
- View Anonymous Posts
- Able to post
- Filtered HTML Allowed
- Censored Content