Form Sanitize using filter_var() and html entities() in PHP -
my input must validated using filter_var() , html_entities().
heres code doesn't work:
session_start(); if(empty($_post['add']) === false ) { $name = filter_var(input_post, 'name', filter_sanitize_string); $email = filter_var(input_post, 'email', filter_sanitize_email); $phone = filter_var(input_post, 'phone', filter_sanitize_int); $address = filter_var(input_post, 'address', filter_sanitize_string); } ?>
when test , put "frost" name input comes out in bold not suppose to. after done needs write out $_session['cart']. im lost @ point
from comments far can see: if $_get variable contains array, not posting html form right. use post-ing html <form>
:
<form action="/path/to/script.php" method="post" enctype="multipart/form-data"> <!-- input fields --> </form>
also, peter van der wal said, use filter_input()
function instead of filter_var()
if want use input_post
. otherwise use filter_var($_post['input_name'], filter_sanitize_string)
.
for more post more html code
if new coding/php suggest familiarize w3schools , php documentation. quite useful if understand these resources. way start learning.
Comments
Post a Comment