supanoob Posted June 4, 2006 Share Posted June 4, 2006 well, i want to edit certain fields of my database for players without having to go log into my database all the time. this will also allow me to make it so other people can do so. but it doesnt see to update :Sthis is the code with the fields where they insert what they want the new fields too be.[code]<?phpsession_start();//this code is compyright to supanoob http://www.twottk.com// to use this code you must have his permission to gain// permission please mail him at webmaster@twottk.comrequire_once('header.php');if (!$_SESSION['valid_user']) { echo 'you are not logged in'; die();} $user=$_SESSION['valid_user'];$query="select playerid, user, rank, name, email, gold, fatigue, maxfat, power, speed, dex, intel, health, maxhealth, gender from players where user='$user'";$result=mysql_query($query);if (!$result){die (mysql_error());}$search_query = $_POST['playerid3'];$num_rows=mysql_num_rows($result);$row=mysql_fetch_array($result);$playerid=($row['playerid']);$rank=($row['rank']);$name=($row['name']);$gold=($row['gold']);$user=($row['user']);$fatigue=($row['fatigue']);$maxfat=($row['maxfat']);$power=($row['power']);$speed=($row['speed']);$dex=($row['dex']);$intel=($row['intel']);$health=($row['health']);$maxhealth=($row['maxhealth']);$gender=($row['gender']);$_SESSION['valid_user'] = $user;?><HTML><HEAD><style type="text/css" media="all"> @import "css.php"; </style> <TITLE>TWOTTK.COM</TITLE></HEAD><TABLE width=100% border=0 cellpadding=0 cellspacing=0><TR> <TD colspan=5> <p align="center"> <img src="http://www.twottk.com/game/banner.jpg" width="730" height="160"></p> <TABLE border=0 cellpadding=0 cellspacing=0> <TR><TD> </TD></TR> </TABLE><center><p><nobr><a href="home.php">Home</a> | <a href="town.php">Town</a> |<a href="search.php">Search</a> |<a href="hospital.php">Hospital</a> | <a href="gym.php">Gym</a> | <a href="http://www.twottk.com/forum/">Forum</a> | <a href="account.php">Account</a> | <?php if($rank=='Admin') { echo "<a href=\"admin.php\">Admin Control |</a>"; } ?> <nobr><a href="logout.php">Logout</a></nobr> </center> </TD></TR><TR height=20><TD colspan=5 align=left><!-- SPACER --></TD></TR><TR> <TD align=left width=5><!-- SPACER --></TD> <TD align=left WIDTH=20% valign=top> <TABLE border=0 cellpadding=0 cellspacing=0 height="85" width="164"> <TR> <TD colspan=2 width=164 height="17"><hr></TD> </TR> <TR> <?phprequire_once('cssloggedin.php');?> <TR> <TD colspan=2 width=164 height="30"> Game Stats:<br> Name: <?php echo "$name ($playerid)"; ?><br> Gender: <?php echo "$gender"; ?><br> Gold: <?php echo "$gold"; ?><br> Health: <?php echo "$health / $maxhealth"; ?><br> Fatigue: <?php echo "$fatigue / $maxfat"; ?><hr> <p></TD> </TR> <TR height=20> <TD height="1" width="164"><!-SPACER-></TD> </TR> <TR> <TD colspan=2 width=164 height="1"> </TD> </TR> <TR> <TD width=164 bgcolor=#FFFFFF valign=top height="12"><samp>Logged In: <?php echo date ('jS F'); ?><p></samp></TD> <TD width=1 bgcolor=#FFFFFF height="12"></TD> </TR> <TR> <TD colspan=2 width=164 height="12"><hr> </TD> </TR> </TABLE> <BR> </TD> <TD align=left width=1%><!-- SPACER --></TD> <TD align=left WIDTH=78% valign=top> <TABLE width=744 border=0 cellpadding=0 cellspacing=0 height="12"> <TR> <TD valign=top align=left width=4 height="12"></TD> <TD valign=top align=center background=templates/default/images/menuback.gif width="736" height="12"><hr></TD> <TD valign=top align=right width=4 height="12"></TD> </TR> </TABLE><TABLE width=740 border=0 cellpadding=0 cellspacing=0> <TR> <TD width=1 bgcolor=#FFFFFF></TD> <TD bgcolor=#FFFFFF width="733" > <p align="center"><FORM NAME="searchphone" METHOD="post" ACTION="findedit.php">Enter Player ID: <input name="playerid3" type="text"><BR><input type="submit" name="Submit" value="Submit"></FORM></p><?phpif (!$_POST['playerid3']) { die ('Please enter a players ID you would like to edit.'); }$search_query = trim($_POST['search_query']); $link = mysql_connect($hostname, $username, $password);$query2="SELECT playerid, user, rank, name, email, gold, win, lose, fatigue, maxfat, power, speed, dex, intel, health, maxhealth, gender from players Where playerid = '$playerid3'";$result2= mysql_db_query ($dbname, $query2, $link) or die(mysql_error());$row = mysql_fetch_array($result2);$num = mysql_num_rows($result2);$playerid2=($row['playerid']);$rank2=($row['rank']);$name2=($row['name']);$gold2=($row['gold']);$user2=($row['user']);$fatigue2=($row['fatigue']);$maxfat2=($row['maxfat']);$power2=($row['power']);$speed2=($row['speed']);$dex2=($row['dex']);$intel2=($row['intel']);$health2=($row['health']);$maxhealth2=($row['maxhealth']);$gender2=($row['gender']);$win2=($row['win']);$lose2=($row['lose']);if($num == "0"){echo "Search for $playerid3 returned no results";}else{echo "You are currently going to edit $name2 ($playerid2), all the stats you see are what he currently has.<BR> <hr><br>";}?><form method="POST" action="adminedit.php"> <!--webbot bot="Registration" s-service="Name of your sub web" s-username-fields="Username" s-password-fields="Password PasswordVerify" i-password-min-length="6" b-check-password-against-user="TRUE" u-file="D:\Stefs Work\_private\regdb.txt" s-format="TEXT/TSV" s-label-fields="TRUE" s-builtin-fields="Date Time REMOTE_NAME HTTP_USER_AGENT" s-form-fields="Username EmailAddress" --> <p><span lang="en-gb"><b>Change Stats</b></span><b><span lang="en-gb">:</span></b><br><br> <?php // change speed box ?> <span lang="en-gb">Speed:<br> </span> <input type="text" size="25" name="speed3"> </p> <?php // change dex box ?> <p><span lang="en-gb">Dex:<br> <input type="text" name="dex3" size="25"></span></p> <?php // change power box ?> <p><span lang="en-gb">Power:<br> </span> <input type="text" size="25" name="power3"><br><br> <p><span lang="en-gb"><b>Change Health and Fatigue</b></span><b><span lang="en-gb">:</span></b><br><br> <?php // change max health box ?> <span lang="en-gb">Max Health:<br> </span> <input type="text" size="25" name="maxhealth3"> </p> <?php // change health box ?> <p><span lang="en-gb">Health:<br> <input type="text" name="health3" size="25"></span></p> <?php // change max fatigue box ?> <p><span lang="en-gb">Max Fatigue:<br> </span> <input type="text" size="25" name="maxfat3"> <?php // change fatigue box ?> <p><span lang="en-gb">Fatigue:<br> </span> <input type="text" size="25" name="fatigue3"><br><br> <p><span lang="en-gb"><b>Change Wins and Losses</b></span><b><span lang="en-gb">:</span></b><br><br> <?php // change wins box ?> <span lang="en-gb">Wins:<br> </span> <input type="text" size="25" name="win3"> </p> <?php // change losses box ?> <p><span lang="en-gb">Losses:<br> <input type="text" name="lose3" size="25"></span></p><br><br> <p><span lang="en-gb"><b>Change Gold ammount.</b></span><b><span lang="en-gb">:</span></b><br><br> <?php // change max health box ?> <span lang="en-gb">Gold:<br> </span> <input type="text" size="25" name="gold3"> </p> <p><input type="submit" value="Submit"> <input type="reset" value="Reset"></p><br><br><hr> </form></TD> </TR> </TABLE> <p> </p> <TABLE width=748 border=0 cellpadding=0 cellspacing=0 height="39"> <TR> <TD valign=top align=left width=4 height="39"> </TD> <TD align=center background=templates/default/images/menu_bottom.gif width="740" height="39"><hr></TD> <TD valign=top align=right width=4 height="39"> </TD> </TR> </TABLE> <br><CENTER> <p></p> </CENTER> </TD> <TD align=left width=10><!-- SPACER --></TD></TR></TABLE></BODY></HTML>[/code]and this is the actual update page (adminedit.php) this also doesnt echo who it updated midway down where it says stats for () updated.[code]<?phpsession_start();//this code is copyright to supanoob http://www.twottk.com// to use this code you must have his permission to gain// permission please mail him at webmaster@twottk.comrequire_once('header.php');if (!$_SESSION['valid_user']) { echo 'you are not logged in'; die();} $user=$_SESSION['valid_user'];$query="select playerid, user, name, email, gold, win, lose, total, fatigue, maxfat, power, speed, dex, intel, health, maxhealth, gender from players where user='$user'";$result=mysql_query($query);if (!$result){die (mysql_error());}$num_rows=mysql_num_rows($result);$row=mysql_fetch_array($result);$playerid=($row['playerid']);$name=($row['name']);$gold=($row['gold']);$user=($row['user']);$fatigue=($row['fatigue']);$maxfat=($row['maxfat']);$power=($row['power']);$speed=($row['speed']);$dex=($row['dex']);$intel=($row['intel']);$health=($row['health']);$maxhealth=($row['maxhealth']);$gender=($row['gender']);$win=($row['win']);$lose=($row['lose']);$total=($row['total']);$speed4=('speed3');$power4=('power3');$dex4=('dex3');$maxhealth4=('maxhealth3');$health4=('health3');$fatigue4=('fatigue3');$maxfat4=('maxfat3');$win4=('win3');$lose4=('lose3');$gold4=('gold3'); $sql2="UPDATE players SET speed='$speed4', power='$power4', dex='$dex4', maxhealth='$maxhealth4', health='$health4', maxfat='$maxfat4', fatigue='$fatigue4', win='$win4', lose='$lose4', gold='$gold4' WHERE playerid='$playerid3'";if(mysql_query($sql2))?><HTML><HEAD><style type="text/css" media="all"> @import "css.php"; </style> <TITLE>TWOTTK.COM</TITLE></HEAD><TABLE width=100% border=0 cellpadding=0 cellspacing=0><TR> <TD colspan=5> <p align="center"> <img src="http://www.twottk.com/game/banner.jpg" width="730" height="160"></p> <TABLE border=0 cellpadding=0 cellspacing=0> <TR><TD> </TD></TR> </TABLE><center><p><nobr><a href="home.php">Home</a> | <a href="town.php">Town</a> |<a href="search.php">Search</a> |<a href="hospital.php">Hospital</a> | <a href="gym.php">Gym</a> | <a href="http://www.twottk.com/forum/">Forum</a> | <a href="account.php">Account</a> | <nobr><a href="logout.php">Logout</a></nobr> </center> </TD></TR><TR height=20><TD colspan=5 align=left><!-- SPACER --></TD></TR><TR> <TD align=left width=5><!-- SPACER --></TD> <TD align=left WIDTH=20% valign=top> <TABLE border=0 cellpadding=0 cellspacing=0 height="85" width="164"> <TR> <TD colspan=2 width=164 height="17"><hr></TD> </TR> <TR> <?phprequire_once('cssloggedin.php');?> <TR> <TD colspan=2 width=164 height="30"> Game Stats:<br> Name: <?php echo "$name ($playerid)"; ?><br> Gender: <?php echo "$gender"; ?><br> Gold: <?php echo "$gold"; ?><br> Health: <?php echo "$health / $maxhealth"; ?><br> Fatigue: <?php echo "$fatigue / $maxfat"; ?><hr> <p></TD> </TR> <TR height=20> <TD height="1" width="164"><!-SPACER-></TD> </TR> <TR> <TD colspan=2 width=164 height="1"> </TD> </TR> <TR> <TD width=164 bgcolor=#FFFFFF valign=top height="12"><samp>Logged In: <?php echo date ('jS F'); ?><p></samp></TD> <TD width=1 bgcolor=#FFFFFF height="12"></TD> </TR> <TR> <TD colspan=2 width=164 height="12"><hr> </TD> </TR> </TABLE> <BR> </TD> <TD align=left width=1%><!-- SPACER --></TD> <TD align=left WIDTH=78% valign=top> <TABLE width=744 border=0 cellpadding=0 cellspacing=0 height="12"> <TR> <TD valign=top align=left width=4 height="12"></TD> <TD valign=top align=center background=templates/default/images/menuback.gif width="736" height="12"><hr></TD> <TD valign=top align=right width=4 height="12"></TD> </TR> </TABLE><TABLE width=740 border=0 cellpadding=0 cellspacing=0> <TR> <TD width=1 bgcolor=#FFFFFF></TD> <TD bgcolor=#FFFFFF width="733" ><?php // form starts here echo "character stats for $name2($playerid2) Changed.";?> </form> <p> </p> <TABLE width=748 border=0 cellpadding=0 cellspacing=0 height="39"> <TR> <TD valign=top align=left width=4 height="39"> </TD> <TD align=center background=templates/default/images/menu_bottom.gif width="740" height="39"><hr></TD> <TD valign=top align=right width=4 height="39"> </TD> </TR> </TABLE> <br><CENTER> <p></p> </CENTER> </TD> <TD align=left width=10><!-- SPACER --></TD></TR></TABLE></BODY></HTML>[/code] Quote Link to comment https://forums.phpfreaks.com/topic/11168-updating/ Share on other sites More sharing options...
supanoob Posted June 4, 2006 Author Share Posted June 4, 2006 bump Quote Link to comment https://forums.phpfreaks.com/topic/11168-updating/#findComment-41838 Share on other sites More sharing options...
redarrow Posted June 4, 2006 Share Posted June 4, 2006 [!--quoteo(post=380012:date=Jun 4 2006, 08:05 PM:name=supanoob)--][div class=\'quotetop\']QUOTE(supanoob @ Jun 4 2006, 08:05 PM) [snapback]380012[/snapback][/div][div class=\'quotemain\'][!--quotec--]bump[/quote]Give you a clue look at the select statement WHERE and look at the update WHERE statement. Quote Link to comment https://forums.phpfreaks.com/topic/11168-updating/#findComment-41870 Share on other sites More sharing options...
supanoob Posted June 5, 2006 Author Share Posted June 5, 2006 i honestly cant see anything wrong with it :S Quote Link to comment https://forums.phpfreaks.com/topic/11168-updating/#findComment-42068 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.