Jump to content
MakeWebGames

Username color change isn't working?


bloodless2010
 Share

Recommended Posts

Hey guys,

The majority of this mod works, for example it displays the colors everywhere I need it to, and it has the correct column, I can edit the color manually in the MySQL database, for example I used the color green and everywhere where it says my name is in green, but the form to submit the colour doesn't work?

 

function color_change()
{
global $ir,$c,$userid,$h;
print "<h3>Change Name Color</h3>
Below are a list of colors in which you can change your name to with an example of each....

<form action='preferences.php?action=colorchange2' method='post'>
Color: <select name='color' type='dropdown'>
<option value='white'><font color=none>None</font>
<option value='red'><font color=red>Red</font>
<option value='blue'><font color=blue>Blue</font>
<option value='green'><font color=green>Green</font>
<input type='submit' value='Change color' /></form>";
}

function do_color_change()
{
global $db,$ir,$c,$userid,$h;
if($_POST['color'] == none) {
$color = "white";
}
if($_POST['color'] == red) {
$color = "red";
}
if($_POST['color'] == blue) {
$color = "blue";
}
if($_POST['color'] == green) {
$color = "green";
}
mysql_query("UPDATE users SET username_color=$color WHERE userid=$userid");
print "Name Color Changed!<br />";
print "<a href='preferences.php'>Back</a>";
}

 

It does display Name Color Changed! but it doesn't actualy update it. Should be an easy fix, thanks!

Edited by bloodless2010
Link to comment
Share on other sites

are you going to secure your script

and try this

 

mysql_query("UPDATE `users` SET `username_color`='". $color ."' WHERE `userid`='". $userid ."'");

 

Not tested so might not work

 

and also the <font> element is deprecated you should not use it use <span style instead

Edited by urbanmafia
Link to comment
Share on other sites

Hey guys,

The majority of this mod works, for example it displays the colors everywhere I need it to, and it has the correct column, I can edit the color manually in the MySQL database, for example I used the color green and everywhere where it says my name is in green, but the form to submit the colour doesn't work?

function color_change()
{
global $ir,$c,$userid,$h;
print "<h3>Change Name Color</h3>
Below are a list of colors in which you can change your name to with an example of each....

<form action='preferences.php?action=colorchange2' method='post'>
Color: <select name='color' type='dropdown'>
<option value='white'><font color=none>None</font>
<option value='red'><font color=red>Red</font>
<option value='blue'><font color=blue>Blue</font>
<option value='green'><font color=green>Green</font>
<input type='submit' value='Change color' /></form>";
}

function do_color_change()
{
global $db,$ir,$c,$userid,$h;
if($_POST['color'] == none) {
$color = "white";
}
if($_POST['color'] == red) {
$color = "red";
}
if($_POST['color'] == blue) {
$color = "blue";
}
if($_POST['color'] == green) {
$color = "green";
}
mysql_query("UPDATE users SET username_color=$color WHERE userid=$userid");
print "Name Color Changed!<br />";
print "<a href='preferences.php'>Back</a>";
}

It does display Name Color Changed! but it doesn't actualy update it. Should be an easy fix, thanks!

Quote your strings, $_POST['color'] == 'none', so on and so forth.

Link to comment
Share on other sites

Still doesn't work after I quoted the strings.

function color_change()
{
global $ir,$c,$userid,$h;
print "<h3>Change Name Color</h3>
Below are a list of colors in which you can change your name to with an example of each....

<form action='preferences.php?action=colorchange2' method='post'>
Color: <select name='color' type='dropdown'>
<option value='white'><font color=none>None</font>
<option value='red'><font color=red>Red</font>
<option value='blue'><font color=blue>Blue</font>
<option value='green'><font color=green>Green</font>
<input type='submit' value='Change color' /></form>";
}

function do_color_change()
{
global $db,$ir,$c,$userid,$h;
if($_POST['color'] == 'none') {
$color = white;
}
if($_POST['color'] == 'red') {
$color = red;
}
if($_POST['color'] == 'blue') {
$color = blue;
}
if($_POST['color'] == 'green') {
$color = green;
}
mysql_query("UPDATE users SET username_color=$color WHERE userid=$userid");
print "Name Color Changed!<br />";
print "<a href='preferences.php?action=colorchange'>Back</a>";
}
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.

 Share

×
×
  • Create New...