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
who does he look like? He's Linear88 O_o. Lol, I feel stupid for not being able to notice the bugs, even though i have little to no experience coding webs, since I said it looks good. Ah but w/e, I guess we learn by making mistakes first.
Parse error: syntax error, unexpected '=' in D:\xampp\htdocs\Gunz\os\os_changename.php on line 39
Thanks for informing me, fixed it.
Click Thanks if it worked.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;
}
$code = 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 echo $_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 echo $char['CID']; ?>"><?php echo $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>
Um Linear, it turns up as a blank white page :o
A fix again, this time, it was tested.
PHP Code:<?php
// <!-- -->
// Copyright Linear88 for the modifications. Alfredao for the original code.
// <!-- -->
mssql_connect("PCNAME\SQLEXPRESS","sa","YourPasswordHere");
mssql_select_db("GunzDB");
function antisql2($sql)
{
$sql = str_replace("'","''",$sql);
$sql = strip_tags($sql);
$sql = addslashes($sql);
return $sql;
}
$code2 = $_SESSION['AID'];
$code = 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 echo $_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 echo $char['CID']; ?>"><?php echo $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>
Still just a blank page man :o, im on Wamp.
the script works fine. The only thing you need to include with that is a login script so that it can read the characters (unless I'm mistaken). Don't use wamp, it sucks, use appserv.
I use Xampp and it is added to my site (final revolution by ~DN modified by me) and it works great
I am already using AppServ but it stills show as a blank page :x
blank page, fix please? O_O
I managed to view the page, but the drop down box is blank.
And yes short tags are enabled.
In which directory do i have to put it in?
since my webshop items are in the database not in the xampp map if u know what i mean. (X-weaver database) so In which directory do i have to put it in?:ehh:
I get this error at every page =/.Code:Fatal error: Call to undefined function mssql_connect() in C:\wamp\www\User\index.php on line 5
Exept register ODBC 2