I basically trying to capture the input information then print the on the screen. Noted, that I must implement filter input and escape output. Please checked whether this result is correct:
receive.php
<html>
<?php
$nama = isset($_POST['nama']) ? $_POST ['nama'] : '';
$color = isset($_POST['color']) ? $_POST ['color'] : '';
$newnama = htmlspecialchars($nama, ENT_QUOTES);
$newcolor = htmlspecialchars($color, ENT_QUOTES);
RemoveBad($newnama);
RemoveBad($newcolor);
// filter input
function RemoveBad($strTemp) {
$strTemp = $strTemp.replace("/<|>|||%|;|(|)|&|+|-/g","");
return $strTemp;
}
?>
<h1> Print Output </h1>
Nama : <?php echo $newnama ?>
Color : <?php echo $newcolor ?>
</html>
Fatal error: Call to undefined function replace() in C:xampphtdocsphp_exercisereceive.php on line 19
line 19: $strTemp = $strTemp.replace("/<|>|||%|;|(|)|&|+|-/g","");