I have 2 php pages. After submitting the form on page1 it's posted data is being displayed on page2. This works fine but some of characters like '
and "
automatically get a \
just before themselves and the spaces are also gone.
For example I give ' "
on page1. This is displayed as \' \"
on page2. As you see the characters got \
attached and the spaces are also gone.
My code:
Page1.php
<html>
<head>
<title>PAGE 1</title>
</head>
<body>
<form enctype="multipart/form-data" action="page2.php" method="post">
<input type="text" name="txtNaam" id="txtNaam" />
<input type="submit" value="Submit">
</form>
</body>
</html>
Page2.php
<?php
// TEST 1
echo $_POST['txtNaam']; // <== \' \"
echo "<br/>";
// TEST 2
echo rawurlencode($_POST['txtNaam']); // <== %5C%27%20%20%20%20%5C%22
echo "<br/>";
// TEST 3
echo urlencode($_POST['txtNaam']); // <== %5C%27++++%5C%22
?>
How can I get these special characters correctly displayed when they are posted?