Seker Posted August 30, 2012 Share Posted August 30, 2012 I had to re-do my staff edit user function because it just wasn't working for some reason. Now, after re-doing it, it's still not working. It says "User Edited" but it just doesn't do anything. Can anyone spot anything obvious? function edit_user_form() { global $c, $h; $user = abs((INT) $_POST['user']); $d = mysql_query("SELECT u.*,us.* FROM users u LEFT JOIN userstats us on u.userid=us.userid WHERE u.userid={$user}", $c); if ($_POST['nusername']) { $energy = 10 + $_POST['nlevel'] * 2; $nerve = 3 + $_POST['nlevel'] * 2; $hp = 50 + $_POST['nlevel'] * 50; mysql_query("UPDATE users SET username='{$_POST['nusername']}',level={$_POST['nlevel']},money={$_POST['nmoney']},crystals={$_POST['ncrystals']},energy=$energy,brave=$nerve,maxbrave=$nerve,maxenergy=$energy,hp=$hp,maxhp=$hp,hospital={$_POST['nhospital']},jail={$_POST['njail']},gang={$_POST['ngang']},donatordays={$_POST['ndonatordays']},display_pic='{$_POST['ndisplay_pic']}',bankmoney={$_POST['nbankmoney']} WHERE userid={$user}") or die(mysql_error()); mysql_query("UPDATE userstats SET strength={$_POST['nstrength']},agility={$_POST['nagility']},guard={$_POST['nguard']},labour={$_POST['nlabour']},IQ={$_POST['nIQ']} WHERE userid={$user}") or die(mysql_error()); print "User Edited!"; } else { $ue = mysql_fetch_array($d); if ($ue['display_pic']) { $pic = $ue['display_pic']; } else { $pic = "http://districtwars.net/pics/default.png"; } print " <table width='590px' border='2'> <tr> <td align='center'> <form action='new_staff.php?action=edituserform' method='post' /> Username: <input type='text' name='nusername' value='{$ue['username']}' /><br /> Level: <input type='text' name='nlevel' value='{$ue['level']}' /><br /> Gold: <input type='text' name='nmoney' value='{$ue['money']}' /><br /> Tokens: <input type='text' name='ncrystals' value='{$ue['crystals']}' /><br /> Hospital Time: <input type='text' name='nhospital' value='{$ue['hospital']}' /><br /> Jail Time: <input type='text' name='njail' value='{$ue['jail']}' /><br /> Gang ID: <input type='text' name='ngang' value='{$ue['gang']}' /><br /> Donator Days: <input type='text' name='ndonatordays' value='{$ue['donatordays']}' /><br /> Display Pic: <input type='text' name='ndisplay_pic' value='{$pic}' /><br /> Gold Storage: <input type='text' name='nbankmoney' value='{$ue['bankmoney']}' /><br /> Strength: <input type='text' name='nstrength' value='{$ue['strength']}' /><br /> Agility: <input type='text' name='nagility' value='{$ue['agility']}' /><br /> Guard: <input type='text' name='nguard' value='{$ue['guard']}' /><br /> Labour: <input type='text' name='nlabour' value='{$ue['labour']}' /><br /> IQ: <input type='text' name='nIQ' value='{$ue['IQ']}' /><br /> <input type='submit' value='Edit User' /></form> </td> </tr> </table>"; } } Quote Link to comment Share on other sites More sharing options...
newttster Posted August 30, 2012 Share Posted August 30, 2012 I could be wrong ... but where are you gathering the data for the nlevel, nomoney, ncrystals etc? Where are you declaring that they have to be set (isset)? Quote Link to comment Share on other sites More sharing options...
Seker Posted August 30, 2012 Author Share Posted August 30, 2012 I could be wrong ... but where are you gathering the data for the nlevel, nomoney, ncrystals etc? Where are you declaring that they have to be set (isset)? Well, as far as gathering the data, I left the default as is, and it collects and displays the information correctly. It's just, when you change it (The n* values are the new values you place in the form) it doesn't update. Quote Link to comment Share on other sites More sharing options...
newttster Posted August 30, 2012 Share Posted August 30, 2012 I'm not sure how v1 works ... but in v2 certain fields have to be filled or it throws an error. *shrugs* Quote Link to comment Share on other sites More sharing options...
Seker Posted August 30, 2012 Author Share Posted August 30, 2012 Well, that's the thing, it's all filled. Every line has a value when you select the user. There's no reason it would stop it because some of those values are 0, would it? I mean, it's not throwing any errors. It's just not updating. Quote Link to comment Share on other sites More sharing options...
newttster Posted August 30, 2012 Share Posted August 30, 2012 You are editing, right ... not creating a new one from what I can see. Could it have to do with the field not being defined in your table? Or it's a different type of field. int instead of decimal ... or vice versa? Just throwing some ideas that have snagged me in the past. Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted August 30, 2012 Share Posted August 30, 2012 (edited) where you have $user = abs((INT) $_POST['user']); try changing it to $_GET instead of POST, could be the reason why it's not updating, that i can think of. I dunno it does not look right to use $_POST at the end of the query part userid={$user} usually it is $_GET. I maybe wrong i just have never used POST at the end. Edited August 30, 2012 by lucky3809 Quote Link to comment Share on other sites More sharing options...
Seker Posted August 30, 2012 Author Share Posted August 30, 2012 where you have $user = abs((INT) $_POST['user']); try changing it to $_GET instead of POST, could be the reason why it's not updating, that i can think of. I dunno it does not look right to use $_POST at the end of the query part userid={$user} usually it is $_GET. I maybe wrong i just have never used POST at the end. Well, it's coming from this, so I assumed POST would be right. Especially because I just tried changing it to GET and it came up with blank fields. :P function edit_user_begin() { global $ir, $c, $h, $userid; print "<h3>Editing User</h3> You can edit any aspect of this user. <br /> <form action='new_staff.php?action=edituserform' method='post'> User: " . user_dropdown($c, 'user') . "<br /> <input type='submit' value='Edit User' /></form> OR enter a user ID to edit: <form action='new_staff.php?action=edituserform' method='post'> User: <input type='text' name='user' value='0' /><br /> <input type='submit' value='Edit User' /></form>"; } Quote Link to comment Share on other sites More sharing options...
lucky3809 Posted August 30, 2012 Share Posted August 30, 2012 have you tried putting quotes around your fields in your queries that look like {$_POST['ndisplay_pic']} i dont know why but sometimes it has worked for others, there was a post not to long ago a user had the same problem but can't remember how it was solved unless I searched lol Quote Link to comment Share on other sites More sharing options...
Seker Posted August 30, 2012 Author Share Posted August 30, 2012 Going to try echoing everything out. Maybe it's just not getting one specific thing. I don't know. Like I said, it's not throwing an error, so this is beyond frustrating. Quote Link to comment Share on other sites More sharing options...
Seker Posted August 30, 2012 Author Share Posted August 30, 2012 Well, printing the new values was no help, as it's showing everything to be correct. It just refuses to update the database. I am so lost. Quote Link to comment Share on other sites More sharing options...
Seker Posted August 30, 2012 Author Share Posted August 30, 2012 Okay. Got it working. Something I totally missed in the original script. On the form to type in the updates, I had to redeclare the userid. So, I added: <input type='hidden' name='userchoice' value='{$user}' /> Quote Link to comment Share on other sites More sharing options...
newttster Posted August 30, 2012 Share Posted August 30, 2012 Congratz! Good job! 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.