Jump to content
MakeWebGames

Race mod


peterisgb

Recommended Posts

Hi, below is the race mod, i dunno whats wrong with it, i just cant figure it out, can anyone help,

It shows that its done it but when i go and check it dont to have seemed to have posted it into the database,

Its probs something so simple but i cant see it, thanks.

-------------------------------------------------------------------------------------------------------------------------------------------------

case 'racechange2':

do_race_change();

break;

case 'racechange':

conf_race_change();

break;

-------------------------------------------------------------------------------------------------------------------------------------------------

function conf_race_change()

{

global $ir,$c,$userid,$h;

print "<center>Race Change<br />

<form action='preferences.php?action=racechange2' method='post'>

<select class='textbox' name='myrace'>

<option value='Wizard'>Wizard</option>

<option value='Ware Wolf'>Ware Wolf</option>

<option value='Vampire'>Vampire</option>

<option value='Yeti'>Yeti</option>

<option value='Elf'>Elf</option>

<option value='Zombie'>Zombie</option>

<option value='Beast'>Beast</option>

<option value='Dwarf'>Dwarf</option>

<option value='Gangsta'>Gangsta</option>

<option value='Criminal'>Criminal</option>

<option value='Pimp'>Pimp</option>

<option value='Member'>Member</option>

<option value='God'>God</option>

<option value='Pilot'>Pilot</option>

<option value='Boxer'>Boxer</option>

<option value='Chief'>Chief</option>

<option value='Cop'>Cop</option>

<option value='Creature'>Creature</option>

<option value='Seller'>Seller</option>

<option value='Buyer'>Buyer</option>

<option value='Goth'>Goth</option>

<option value='Thief'>Thief</option>

<option value='Hacker'>Hacker</option>

<option value='Skeleton'>Skeleton</option>

<option value='Demon'>Demon</option>

<option value='Goblin'>Goblin</option>

<option value='Unknown' SELECTED>Unknown</option>

</Select>

<input class='textbox' type='submit' value='Change Race' />

</form>";

}

function do_race_change()

{

global $db,$ir,$c,$userid,$h;

$db->query("UPDATE users SET myrace='{$_POST['myrace']}' WHERE userid=$userid");

print "You Have Changed your Race Type!<br />

<a href='preferences.php'>Back</a>";

-------------------------------------------------------------------------------------------------------------------------------------------------

ALTER TABLE `users` ADD `myrace` enum('Wizard','Unknown','Ware Wolf','Vampire','Elf','Yeti','Zombie','Beast','Dwarf','Gangsta','Criminal','Pimp','Member','God','Pilot','Boxer','Chief','Cop','Creature','Seller','Buyer','Goth','Thief','Hacker','Skeleton','Demon','Goblin') NOT NULL default 'Unknown'

-------------------------------------------------------------------------------------------------------------------------------------------------

Edited by peterisgb
missed out info
Link to comment
Share on other sites

Did you run the alter query so your table actually has that column?

You could try separate the variables out of the PHP and see if that works. I hate seeing strings and vars mixed together. So try.

 

$db->query("UPDATE users SET myrace=" . $_POST['myrace'] . " WHERE userid=" . intval($userid) . ")";

 

Please please say you'll add some cleaning to this. What stops me from using firebug. Editing the value of that dropdown to like some nasty sql query. Your script will pull it right in and execute it. Unless dB->query() runs some cleaning. I haven't ever looked at mccodes.

Link to comment
Share on other sites

Did you run the alter query so your table actually has that column?

You could try separate the variables out of the PHP and see if that works. I hate seeing strings and vars mixed together. So try.

 

$db->query("UPDATE users SET myrace=" . $_POST['myrace'] . " WHERE userid=" . intval($userid) . ")";

 

Please please say you'll add some cleaning to this. What stops me from using firebug. Editing the value of that dropdown to like some nasty sql query. Your script will pull it right in and execute it. Unless dB->query() runs some cleaning. I haven't ever looked at mccodes.

nice code but nope

Parse error: syntax error, unexpected T_STRING in /home/a6998742/public_html/game/preferences.php on line 248

Link to comment
Share on other sites

the change gender dont work either...

i cant change gender either so there must be something wrong on the page.

i cant find it at all

i'll post the whole page to see if this helps.

 

<?php
include "globals.php";
switch($_GET['action'])
{
case 'colchange2':
do_col_change();
break;

case 'colchange':
col_change();
break;

case 'sexchange2':
do_sex_change();
break;

case 'sexchange':
conf_sex_change();
break;

case 'racechange2':
do_race_change();
break;

case 'racechange':
conf_race_change();
break;

case 'passchange2':
do_pass_change();
break;

case 'passchange':
pass_change();
break;

case 'namechange2':
do_name_change();
break;

case 'namechange':
name_change();
break;

case 'namegchange2':
do_nameg_change();
break;

case 'namegchange':
nameg_change();
break;

case 'picchange2':
do_pic_change();
break;

case 'picchange':
pic_change();
break;

case 'signaturechange2':
do_signature_change();
break;

case 'signaturechange':
signature_change();
break;

case 'forumchange2':
do_forum_change();
break;

case 'forumchange':
forum_change();
break;

default:
prefs_home();
break;
}
function prefs_home()
{
global $db,$ir,$c,$userid,$h;
print "<h3>Preferences</h3>
<a href='preferences.php?action=sexchange'>Sex Change</a><br />
<a href='preferences.php?action=passchange'>Password Change</a><br />
<a href='preferences.php?action=namechange'>Name Change</a><br />
<a href='preferences.php?action=namegchange'>Gang Tag Change</a><br />
<a href='preferences.php?action=racechange'>Race Change</a><br />
<a href='preferences.php?action=picchange'>Display Pic Change</a><br />
<a href='preferences.php?action=forumchange'>Forum Info Change</a><br />
<a href='preferences.php?action=signaturechange'>Sig Change</a><br />
<a href='preferences.php?action=colchange'>Change Chat Room Font colour</a><br />
<hr />

";
}
function signature_change()
{
global $ir,$c,$userid,$h;
print "<h3>Profile Signature Change</h3>
<form action='preferences.php?action=signaturechange2' method='post'>
New Profile Signature: <textarea rows=30 cols=90 name='newsignature' wrap='virtual' class='input'>{$ir['profileSIG']}</textarea>
<input type='submit' value='Change Signature' /></form>
<small>> </small><a href='preferences.php'>Back</a>";
}
function do_signature_change()
{
global $db,$ir,$c,$userid,$h;
if($_POST['newsignature'] == "")
{
print "You did not enter a new profile signature.
<small>> </small><a href='preferences.php?action=signaturechange'>Back  </a>";
}
else
{
$db->query("UPDATE users SET profileSIG='{$_POST['newsignature']}' WHERE userid=$userid");
print "Profile Signature changed!
<small>> </small><a href='preferences.php'>Back</a>";
}
}
function conf_sex_change()
{
global $ir,$c,$userid,$h;
if($ir['gender'] == "Male") { $g="Female"; } else { $g="Male"; }
print "Are you sure you want to become a $g?
<a href='preferences.php?action=sexchange2'>Yes</a> | <a href='preferences.php'>No</a>";
}
function do_sex_change()
{
global $db,$ir,$c,$userid,$h;
if($ir['gender'] == "Male") { $g="Female"; } else { $g="Male"; }
$db->query("UPDATE users SET gender='$g' WHERE userid=$userid");
print "Success, you are now $g!
<a href='preferences.php'>Back</a>";
}
function pass_change()
{
global $ir,$c,$userid,$h;
print "<h3>Password Change</h3><form action='preferences.php?action=passchange2' method='post'>Current Password: <input type='password' name='oldpw' /><br />
New Password: <input type='password' name='newpw' /><br />
Confirm: <input type='password' name='newpw2' /><br />
<input type='submit' value='Change PW' /></form>";
}
function do_pass_change()
{
global $db,$ir,$c,$userid,$h;
if(md5($_POST['oldpw']) != $ir['userpass'])
{
print "The current password you entered was wrong.
<a href='preferences.php?action=passchange'>> Back</a>";
}
else if($_POST['newpw'] !== $_POST['newpw2'])
{
print "The new passwords you entered did not match!
<a href='preferences.php?action=passchange'>> Back</a>";
}
else
{
$db->query("UPDATE users SET userpass=md5('{$_POST['newpw']}') WHERE userid=$userid");
print "Password changed!";
}
}
function name_change()
{
global $ir,$c,$userid,$h;
print "<h3>Name Change</h3>
Please note that you still use the same name to login, this procedure simply changes the name that is displayed. <form action='preferences.php?action=namechange2' method='post'>
New Name: <input type='text' name='newname' />
<input type='submit' value='Change Name' /></form>";
}
function do_name_change()
{
global $db,$ir,$c,$userid,$h;
if($_POST['newname'] == "")
{
print "You did not enter a new name.
<a href='preferences.php?action=namechange'>> Back</a>";
}
else
{
$_POST['newname']=str_replace(array("<", ">", "\\\'"), array("<", ">", "'"), $_POST['newname']);
$db->query("UPDATE users SET username='{$_POST['newname']}' WHERE userid=$userid");
print "Username changed!";
}
}

function nameg_change()
{
global $ir,$c,$userid,$h;
print "<h3>Gang Tag Change</h3>
<form action='preferences.php?action=namegchange2' method='post'>
New Tag: <input type='text' name='newnameg' /><br />
<input type='submit' value='Change Tag' /></form>";
}
function do_nameg_change()
{
global $db,$ir,$c,$userid,$h;
if($_POST['newnameg'] == "")
{
print "You did not enter a new name.<br />
<a href='preferences.php?action=namechange'>> Back</a>";
}
else
{
global $db,$ir,$c,$userid,$h;
$db->query("UPDATE users SET yourgangPREF='{$_POST['newnameg']}' WHERE userid=$userid");
print "Tag changed!";
} 

} 
function conf_race_change()
{
global $ir,$c,$userid,$h;
print "<center><hr width='20%'>Race Change<hr width='20%'><br />
Mail Admins to select your race untill this is fixed, thanks <br />
<form action='preferences.php?action=racechange2' method='post'>
<select class=textbox name='race'>
<option value='Wizard'>Wizard</option>
<option value='Unknown'>Unknown</option>
<option value='Ware Wolf'>Ware Wolf</option>
<option value='Vampire'>Vampire</option>
<option value='Yeti'>Yeti</option>
<option value='Elf'>Elf</option>
<option value='Zombie'>Zombie</option>
<option value='Beast'>Beast</option>
<option value='Dwarf'>Dwarf</option>
<option value='Gangsta'>Gangsta</option>
<option value='Criminal'>Criminal</option>
<option value='Pimp'>Pimp</option>
<option value='Member'>Member</option>
<option value='God'>God</option>
<option value='Pilot'>Pilot</option>
<option value='Boxer'>Boxer</option>
<option value='Chief'>Chief</option>
<option value='Cop'>Cop</option>
<option value='Creature'>Creature</option>
<option value='Seller'>Seller</option>
<option value='Buyer'>Buyer</option>
<option value='Goth'>Goth</option>
<option value='Thief'>Thief</option>
<option value='Hacker'>Hacker</option>
<option value='Skeleton'>Skeleton</option>
<option value='Demon'>Demon</option>
<option value='Goblin'>Goblin</option>
<option value='Unknown' SELECTED>Unknown</option>
</Select>
<input class='textbox' type='submit' value='Change Race' />
</form>";
}
function do_race_change()
{
global $db,$ir,$c,$userid,$h;
$db->query("UPDATE users SET race='{$_POST['race']}' WHERE userid=$userid");
print "You Have Changed your Race Type!
<a href='preferences.php'>Back</a>";
}




















function pic_change()
{
global $ir,$c,$userid,$h;
print "<h3>Pic Change</h3>
Please note that this must be externally hosted, <a href='http://imageshack.us'>ImageShack</a> is our recommendation.
Any images that are not 150x150 will be automatically resized <form action='preferences.php?action=picchange2' method='post'>
New Pic: <input type='text' name='newpic' value='{$ir['display_pic']}' />
<input type='submit' value='Change Name' /></form>";
}
function do_pic_change()
{
global $db,$ir,$c,$userid,$h;
if($_POST['newpic'] == "")
{
print "You did not enter a new pic.
<a href='preferences.php?action=picchange'>> Back</a>";
}
else
{
$_POST['newpic']=str_replace('\\\'',''', $_POST['newpic']);
$db->query("UPDATE users SET display_pic='{$_POST['newpic']}' WHERE userid=$userid");
print "Pic changed!";
}
}
function forum_change()
{
global $ir,$c,$userid,$h;
print "<h3>Forum Info Change</h3>
Please note that the avatar must be externally hosted, <a href='http://imageshack.us'>ImageShack</a> is our recommendation.
Any avatars that are not 100x100 will be automatically resized <form action='preferences.php?action=forumchange2' method='post'>
Avatar: <input type='text' name='forums_avatar' value='{$ir['forums_avatar']}' />
Signature (you may use BBcode): <textarea rows=10 cols=50 name='forums_signature'>{$ir['forums_signature']}</textarea>
<input type='submit' value='Change Info' /></form>";
}
function do_forum_change()
{
global $db,$ir,$c,$userid,$h;
$_POST['forums_avatar']=str_replace(array("<", ">"), array("<", ">"), $_POST['forums_avatar']);
$db->query("UPDATE users SET forums_avatar='{$_POST['forums_avatar']}', forums_signature='{$_POST['forums_signature']}' WHERE userid=$userid");
print "Forum Info changed!";
}
function col_change()
{
global $ir,$c,$userid,$h;
print "<h3>Change chat font colour</h3>

<form action='preferences.php?action=colchange2' method='post'>
Chat Colour: <input type='text' name='colour' value='{$ir['colour']}' />


<input type='submit' value='Change font colour' /></form>";
}
function do_col_change()
{
global $db,$ir,$c,$userid,$h;
$db->query("UPDATE users SET colour='{$_POST['colour']}', colour='{$_POST['colour']}' WHERE userid=$userid");
print "colour changed!";
}

$h->endpage();
?>

 

i just tested the db query on posting the race to the database and that code does work,

do it has to be the page somewhere....

:'(

Edited by peterisgb
update
Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...