I have a input inside of <form action="include_php/update.inc.php" method="POST"> </form>
like this
<input type="text" id="username" name="new-username" value="<?php echo $result['user_name']?>">
<input type="text" id="password" name="new-password" value="<?php echo $result['user_password']?>">
And i am trying to read value of this input to check something. Here is the Post Codes.
When i try to only update my password. It goes first if even if there is a data inside of it.
$userName=$_POST['new-username'];
$userPassword=$_POST['new-password'];
if($_SESSION['userName'] !== $userName){
$sql="UPDATE users SET user_name='$userName' WHERE user_id='$id'";
$query=mysqli_query($conn,$sql);
}
elseif($_SESSION['userPassword'] !== $userPassword){
$sql="UPDATE users SET user_password='$userPassword' WHERE user_id='$id'";
$query=mysqli_query($conn,$sql);
header("Location:http://localhost/talktoworldx/Anasayfa/account/index.php#success=update");
}
But $userName
has already value from database but it return nothing.
and it becomes like this if($_SESSION['userName'] !== "" )
and it goes first if and change username to empty.
Maybe i am making really small mistake here but i couldnt figure out this.
So how can i send this value as POST method ?