This topic is locked
[SOLVED]

 User Registration Cont.

9/8/2010 8:59:13 AM
PHPRunner General questions
W
wildwally author

Is it possible to create the username based on text string and ID of the person registering? I was able to get the field to read this in a view as custom code; however, the true value was what the person registered with.
Since erased the working version but it looked like:


$value="TEXT".$data["ID"];


Each username in the list looks (view as) correct, but i want it to actually be this (so a user would log in with TEXT20 if they were the 20th person in the db).

W
wildwally author 9/8/2010

After a lot of testing and pulling code apart and echoing it to see what was happening I finally found a solution to my problem. Here is the solution for all of you in the future trying to do something similiar.


global $conn;

//** Get the ID # to use in the future username

$rs=CustomQuery("SELECT ID FROM _users WHERE Email = '".$userdata["Email"]."'");

$data=db_fetch_array($rs);

//** Combine the text string with the ID #

$new="TEXT".$data["ID"];

//** Update the field

$strUpdate= "UPDATE _users SET Username = '$new' WHERE Email = '".$userdata["Email"]."'";

CustomQuery($strUpdate);

return true;