htmlentities is not wroking, it should escape quotes but is does not.
<?php
session_start();
session_regenerate_id( true );
if(isset($_REQUEST['sub'])){
echo $name = htmlspecialchars($_REQUEST['email'] );
echo $pswd = $_REQUEST['pswd'];
echo $abc = htmlentities($pswd ,ENT_QUOTES, "UTF-8");
//echo $pswd = htmlentities("hello" ,ENT_QUOTES);
}
?>
<html lang="en">
<head>
<title>Bootstrap Example</title>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/css/bootstrap.min.css">
<script src="https://ajax.googleapis.com/ajax/libs/jquery/3.4.0/jquery.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/popper.js/1.14.7/umd/popper.min.js"></script>
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/4.3.1/js/bootstrap.min.js"></script>
</head>
<body>
<div class="container">
<h2>Login form</h2>
<form action="" method="POST">
<div class="form-group">
<label for="email">Email:</label>
<input type="email" class="form-control" id="email" placeholder="Enter email" name="email" required>
</div>
<div class="form-group">
<label for="pwd">Password:</label>
<input type="password" class="form-control" id="pwd" placeholder="Enter password" name="pswd" required>
</div>
<button type="submit" class="btn btn-primary" name="sub">Submit</button>
</form>
</div>
</body>
</html>
You can see 1 line is comment, If I pass a value with quotes in htmlentites(), It outputs the value without quotes, But If I am passing a value from my form, suppose I passed "hello". " " are included. And store this value in php variable and then pass this variable in htmlentites(). It shows output in "", But it should ignore quotes.