mxyi Posted July 3, 2010 Share Posted July 3, 2010 hey i recently added a color change method for donators, i added username_color to the user SQL table here are the username color cases in preferences.php case 'colorchange2': do_color_change(); break; case 'colorchange': color_change(); break; and here is the code... 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='lime'>None <option value='red'>RED <option value='blue'>BLUE <option value='green'>GREEN <input type='submit' value='Change color' /></form>"; } function do_color_change() { global $db,$ir,$c,$userid,$h; if($_POST['color'] == none) { $color = lime; } if($_POST['color'] == red) { $color = red; } if($_POST['color'] == blue) { $color = blue; } if($_POST['color'] == green) { $color = green; } $db->query("UPDATE users SET username_color=$color WHERE userid=$userid"); print "Name Color Changed!"; } and this happens : is there a way of adding a button to it so it can submit the info to the database? please help! i really need a button to submit the info the the database but i got no idea how to do it :( thank you! Quote Link to comment Share on other sites More sharing options...
Danny696 Posted July 3, 2010 Share Posted July 3, 2010 Change $color = green; to $color = 'green'; And for the others. <option value='lime'>None << bad XHTML ;) <option value='lime'>None</option> << Good XHTML :) Quote Link to comment Share on other sites More sharing options...
mxyi Posted July 3, 2010 Author Share Posted July 3, 2010 i got a error QUERY ERROR: Unknown column 'red' in 'field list' Query was UPDATE users SET username_color=red WHERE userid=1 Quote Link to comment Share on other sites More sharing options...
Danny696 Posted July 3, 2010 Share Posted July 3, 2010 $db->query("UPDATE users SET username_color=$color WHERE userid=$userid"); Change to $db->query("UPDATE users SET username_color='$color' WHERE userid=$userid"); Quote Link to comment Share on other sites More sharing options...
mxyi Posted July 3, 2010 Author Share Posted July 3, 2010 you are deh uber leet! THANK YOU! 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.