onthespot Posted August 6, 2009 Share Posted August 6, 2009 Ok so the following pieces of code work in the order I shal post them. Passing information from one piece to another, in order to eventually change a field in the DB. This is the initial form the user enters into <form action="process.php" method="POST" class="style1"> <table align="center" width="90%" style='border: 1px dotted;' bgcolor="#eeeeee" cellspacing="0" cellpadding="3"> <tr> <td>Xbox360gt:</td> <td><input type="text" name="x360gt" value="<?php if($form->value("x360gt") == "") {echo $session->userinfo['x360gt'];} else {echo $form->value("x360gt");} ?>" /></td> <td><?php echo $form->error("x360gt"); ?></td> </tr> <tr><td colspan="2" align="right"> <input type="hidden" name="subedit" value="1"> <input type="submit" value="Edit Gamertag"></td></tr> <tr><td colspan="2" align="left"></td></tr> </table> </form> Then function procEditAccountGT(){ global $session, $form; // Account edit attempt $retval = $session->editAccountGT($_POST['x360gt']); //Account edit successful if($retval){ $_SESSION['usersettings'] = true; $session->referrer .= (preg_match('#\?#', $session->referrer)) ? '&user='.$session->username : '?user='.$session->username; header("Location: ".$session->referrer); } // Error found with form else{ $_SESSION['value_array'] = $_POST; $_SESSION['error_array'] = $form->getErrorArray(); $session->referrer .= (preg_match('#\?#', $session->referrer)) ? '&user='.$session->username : '?user='.$session->username; header("Location: ".$session->referrer); } } Then function editAccountGT($subx360gt){ global $database, $form; //The database and form object /*360 gt error checking */ $field = "x360gt"; if(!$subx360gt || strlen($subx360gt = trim($subx360gt)) == 0){ $form->setError($field, "* gamertag not entered"); } $subx360gt = stripslashes($subx360gt); /* Errors exist, have user correct them */ if($form->num_errors > 0){ return false; //Errors with form } //change xbox360 gamertag if($subx360gt) { $database->updateUserField($this->username,"x360gt",$subx360gt); } /* Success! */ return true; } And finally function updateUserField($username, $field, $value){ $q = "UPDATE ".TBL_USERS." SET ".$field." = '$value' WHERE username = '$username'"; return mysql_query($q, $this->connection); } My problem is the data is not being altered in the DB, could anyone help me here? I have spent around an hour trying to work the problem out. THankyou Quote Link to comment https://forums.phpfreaks.com/topic/169077-solved-edit-a-field/ 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.