Anybody has hands on a name-changer script for in-game characters name? That lets you log in, then select your character and new name, but leaving a record ANYWHERE of the character's previous username? :o
Printable View
Anybody has hands on a name-changer script for in-game characters name? That lets you log in, then select your character and new name, but leaving a record ANYWHERE of the character's previous username? :o
Code it yourslef or use the CP its release XD
I'll give a brief description on what to do.
Do an mssql_connect and mssql_select_db with your website.
When a user fills in the form, antisql the $_POST values and verify it with mssql_query.
Use a drop down box to request all characters of the account using mssql_query.
Use a text box for new name, and antisql the $_POST value.
Create a new column in your DB called OldName.
Store the value of the old name to OldName using mssql_query.
Update the value of Name using mssql_query.
That's all.
You're done.
Yeah I'd love to have it too.
700th Post :D
lol @ phoenix.. btw congooo
@# topic: even i want that :|
It's pretty easy to make...you need to know little to know php at all. Even i could make this o.o. Just use cobraPanel as a template, and edit the scripts it uses.
I coded a simple page for you.
PHP Code:<?
function sqlseguro($sql)
{
$sql = str_replace("'","''",$sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
return $sql;
}
$codigo = mssql_query("SELECT * FROM Login(nolock) WHERE AID = {$_SESSION['AID']}");
if( isset($_POST['mudarnome']) )
{
$cid = sqlseguro($_POST['cid']);
$nnome = sqlseguro($_POST['nnome']);
$query = mssql_query("SELECT Name FROM Character WHERE Name = '$nnome'");
if( mssql_num_rows($query) != 0 )
{
echo "<script> alert('A Character with this name already exists')</script>";
die();
}
else
{
mssql_query("UPDATE Character SET Name = '$nnome' WHERE CID = '$cid'");
echo "<script> alert('Name changed succesfully')</script>";
die();
}
}
?>
<form method="post" action="<?=$_SERVER['PHP_SELF']?>">
<b>Change: </b><select size="1" name="cid">
<?
$codigo1 = mssql_query("SELECT * FROM Character(nolock) WHERE AID = {$_SESSION['AID']} AND CharNum != '-1'");
while( $char = mssql_fetch_assoc($codigo1) )
{
?>
<option value="<?=$char['CID']?>"><?=$char['Name']?></option>
<?
}
?>
</select>
<b> To: </b>
<input type="text" name="nnome" size="20" maxlength="12">
<input type="submit" name="mudarnome" value="Change Name">
</form>
Nice script. It looks good in my opinion. I think there are a few other things you could add for your antisql thing, but who really cares. At least u made it :P. Btw quick question: Aren't we gonna be needing to translate the nnome and mudarnome into english, or is it supposed to be like that?
Thanks for your help, but it doesn't work :o
http://i37.tinypic.com/9i8ob9.jpg
try changing
to:Code:echo "<script> alert('A Character with this name already exists')</script>
(don't forget the semicolon after the quotation mark).Code:echo "A Character with this name already exists"
now this is all it shows on my page :
alert('Name changed succesfully')"; die(); } } ?>
Change: To:
theres a dropdown menu next to change but i can't select anything, and if i type something into "to" and press enter, i get this:
Code:Forbidden
You don't have permission to access /< on this server.
@alfredao: There are numerous amounts of bugs that you have in your script. Anyway, I won't fix them, since it is just a regular page.
Here's the fixed code, without the errors you mentioned earlier.
changecharname.php
Enjoy.PHP Code:<?php
// <!-- -->
// Copyright Linear88 for the modifications. Alfredao for the original code.
// <!-- -->
function antisql2($sql)
{
$sql = str_replace("'","''",$sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
return $sql;
}
$codigo = mssql_query("SELECT * FROM Login(nolock) WHERE AID = " . $_SESSION['AID'] . "");
if( isset($_POST['changename']) )
{
$cid = antisql2($_POST['cid']);
$charname = antisql2($_POST['charname']);
$query = mssql_query("SELECT Name FROM Character WHERE Name = '$charname'");
if( mssql_num_rows($query) != 0 )
{
echo "<script>alert('A Character with this name already exists!');</script>";
die();
}
else
{
mssql_query("UPDATE Character SET Name = '$charname' WHERE CID = '$cid'");
echo "<script>alert('Name changed successfully!');</script>";
die();
}
}
?>
<form method="post" action="<?php=$_SERVER['PHP_SELF']?>">
<b>Change: </b><select size="1" name="cid">
<?php
$code1 = mssql_query("SELECT * FROM Character(nolock) WHERE AID = " . $_SESSION['AID'] . " AND CharNum != '-1'");
while( $char = mssql_fetch_assoc($code1) )
{
?>
<option value="<?php=$char['CID']?>"><?php=$char['Name']?></option>
<?php
}
?>
</select>
<b> To: </b>
<input type="text" name="charname" size="20" maxlength="12">
<input type="submit" name="changename" value="Change Name">
</form>
Thanks linear.
offtopic: who are you :o