Menu
Forums
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Trending
What's new
New posts
New profile posts
Latest activity
Members
Current visitors
New profile posts
Search profile posts
Upgrades
Log in
Register
What's new
Search
Search
Search titles only
By:
All threads
Latest threads
New posts
Trending threads
New posts
Search forums
Menu
Log in
Register
Navigation
Install the app
Install
More options
Contact us
Close Menu
Forums
Server Development
Habbo Retros
Habbo Q&A
Modifying Username on CMS
JavaScript is disabled. For a better experience, please enable JavaScript in your browser before proceeding.
You are using an out of date browser. It may not display this or other websites correctly.
You should upgrade or use an
alternative browser
.
Reply to thread
Message
<blockquote data-quote="Zodiak" data-source="post: 278194" data-attributes="member: 9300"><p>Edit username? you mean edit your own username or a staff editing someone elses username?</p><p>If your referring to a user changing there name via account settings:</p><p>Top of the page add:</p><p>[PHP]<?php</p><p></p><p>$username = mysql_real_escape_string($_POST['username']);</p><p></p><p>if($_POST['update']) {</p><p>$checkuser = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."'");</p><p></p><p>if(mysql_num_rows($checkuser) == 1)</p><p>{</p><p>$error = "Username taken";</p><p>}</p><p>else</p><p>{</p><p>mysql_query("UPDATE `users` SET `username` = ".$username."'' WHERE `username` = '".$_SESSION['user']['username']."'");</p><p>}</p><p>}</p><p></p><p>?>[/PHP]</p><p>And the form:</p><p>[HTML]<form method="post"></p><p><input type="text" name="username" placeholder="username" value="<?php echo $_SESSION['user']['username']; ?>"></p><p><input type="submit" name="update" value="Update Account"></p><p></form[/HTML]</p><p></p><p>Not the most effecient way to code it but it should work, unless I've made a mistake which I may have considering I'm half asleep and rushed on it.</p><p>Note: This won't work if your php is updated, as mysql was deprecated.</p></blockquote><p></p>
[QUOTE="Zodiak, post: 278194, member: 9300"] Edit username? you mean edit your own username or a staff editing someone elses username? If your referring to a user changing there name via account settings: Top of the page add: [PHP]<?php $username = mysql_real_escape_string($_POST['username']); if($_POST['update']) { $checkuser = mysql_query("SELECT * FROM `users` WHERE `username` = '".$username."'"); if(mysql_num_rows($checkuser) == 1) { $error = "Username taken"; } else { mysql_query("UPDATE `users` SET `username` = ".$username."'' WHERE `username` = '".$_SESSION['user']['username']."'"); } } ?>[/PHP] And the form: [HTML]<form method="post"> <input type="text" name="username" placeholder="username" value="<?php echo $_SESSION['user']['username']; ?>"> <input type="submit" name="update" value="Update Account"> </form[/HTML] Not the most effecient way to code it but it should work, unless I've made a mistake which I may have considering I'm half asleep and rushed on it. Note: This won't work if your php is updated, as mysql was deprecated. [/QUOTE]
Insert quotes…
Verification
Post reply
Forums
Server Development
Habbo Retros
Habbo Q&A
Modifying Username on CMS
Top