Ehsan_Nawaz Posted January 20, 2022 Share Posted January 20, 2022 public function UpdateDetails($fn,$ln,$un,$em) { $this->validateFirstname($fn); $this->validateLastname($ln); $this->validatenewEmail($em,$un); if(empty($this->error_array)){ $query = $this->con->prepare("UPDATE users SET firstName=:fn, lastName=:ln, email=:em WHERE username=:un"); $query->bindValue(":fn",$fn); $query->bindValue(":ln",$ln); $query->bindValue(":em",$em); $query->bindValue(":un",$un); return $query->execute(); } return false; } here is my profile page <?php require_once("assest/header.php"); require_once("class/Account.php"); require_once("class/fillterform.php"); require_once("class/Constants.php"); if(isset($_POST["SaveButtonDetails"])) { $account = new Account($con); $firstName = filterform::sanitizerFormstring($_POST["firstName"]); $lastName = filterform::sanitizerFormstring($_POST["lastName"]); $email = filterform::sanitizerFormEmail($_POST["email"]); if($account->UpdateDetails($firstName,$lastName,$email,$userLoggedin)){ //Sucess echo "update"; } else { ///failure echo "No update"; } } ?> <div class="SettingContainers column"> <div class="formSection"> <form method="POST"> <h2> User Details</h2> <?php $user= new User($con,$userLoggedin); $firstName = isset($_POST["firstName"]) ? $_POST["firstName"] : $user->getfirstName(); $lastName = isset($_POST["lastName"]) ? $_POST["lastName"] : $user->getlastName(); $email = isset($_POST["email"]) ? $_POST["email"] : $user->getUsername(); ?> <input type="text" name="firstName" placeholder="Enter First name" value="<?php echo $firstName; ?>"> <input type="text" name="lastName" placeholder="Enter Last Name" value="<?php echo $lastName; ?>"> <input type="email" name="email" placeholder="Pleas Enter Email" value="<?php echo $email; ?>"> <input type="submit" name="SaveButtonDetails" value="Save" > </form> </div> <div class="formSection"> <form method="POST"> <h2> Update Password</h2> <input type="password" name="oldpassword" placeholder="Enter Old PassWord"> <input type="password" name="newpassword" placeholder="Enter New Password"> <input type="password" name="confirmpassword" placeholder="Confirm New Password"> <input type="submit" name="SavepasswordDetails" value="Submit" > </form> </div> </div> The problem is when i can update the data in profile.php page the can't update the data in phpmyadmin and now its (echo No update) Quote Link to comment https://forums.phpfreaks.com/topic/314439-no-update-the-data-in-mysql/ Share on other sites More sharing options...
Barand Posted January 20, 2022 Share Posted January 20, 2022 Where is the value for $userLoggedin coming from? Quote Link to comment https://forums.phpfreaks.com/topic/314439-no-update-the-data-in-mysql/#findComment-1593488 Share on other sites More sharing options...
Ehsan_Nawaz Posted January 21, 2022 Author Share Posted January 21, 2022 IT is Coming form header.php file Quote Link to comment https://forums.phpfreaks.com/topic/314439-no-update-the-data-in-mysql/#findComment-1593500 Share on other sites More sharing options...
gizmola Posted January 21, 2022 Share Posted January 21, 2022 Maybe one of your validations failed, and it set a value in $this->error_array. You check if that's empty, but if it isn't, you just return false, so the value of that array is set to something you don't make that visible. You should probably have a method to return it. class Account { // current code public function getValidationErrors() { return $this->error_array; } } And then your code could be something like: if($account->UpdateDetails($firstName,$lastName,$email,$userLoggedin)){ //Sucess echo "update"; } else { ///failure echo "No update"; echo '<pre>' . explode(PHP_EOL, $account->getValidationErrors()) . '</pre>'; } Quote Link to comment https://forums.phpfreaks.com/topic/314439-no-update-the-data-in-mysql/#findComment-1593502 Share on other sites More sharing options...
Ehsan_Nawaz Posted January 21, 2022 Author Share Posted January 21, 2022 When i add your recommend code in my profile.php page it show me a Expected type 'string'. Found 'array'. Quote Link to comment https://forums.phpfreaks.com/topic/314439-no-update-the-data-in-mysql/#findComment-1593508 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.