bloodless2010 Posted November 17, 2012 Share Posted November 17, 2012 (edited) 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 November 17, 2012 by bloodless2010 Quote Link to comment Share on other sites More sharing options...
URBANZ Posted November 17, 2012 Share Posted November 17, 2012 (edited) 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 November 17, 2012 by urbanmafia Quote Link to comment Share on other sites More sharing options...
bloodless2010 Posted November 17, 2012 Author Share Posted November 17, 2012 case 'colorchange2': do_color_change(); break; case 'colorchange': color_change(); break; is what I have on the top of the page. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted November 17, 2012 Share Posted November 17, 2012 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. Quote Link to comment Share on other sites More sharing options...
bloodless2010 Posted November 17, 2012 Author Share Posted November 17, 2012 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>"; } Quote Link to comment Share on other sites More sharing options...
bloodless2010 Posted November 17, 2012 Author Share Posted November 17, 2012 Fixed it, I had to change $color to '$color' thanks everyone for trying. Quote Link to comment Share on other sites More sharing options...
Djkanna Posted November 17, 2012 Share Posted November 17, 2012 Fixed it, I had to change $color to '$color' thanks everyone for trying. Yes but once again quote your strings, $color = 'string'; :) Quote Link to comment Share on other sites More sharing options...
Lithium Posted November 19, 2012 Share Posted November 19, 2012 yes but once again quote your strings, $color = 'string'; :) string = "" int = ' ' :) Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.