Developer Developer -4 years ago 94
PHP Question

php function filtration for input form

I try to create a function to filter the input field after submit
database connection


this function is like that

function filter($x){
global $conn;


<form method="post">
<input type="text" name="txt_name">
<input type="submit" name="add" value="Add">


$name= filtration($_POST['txt_name']);
echo $name;

When i try to print the $name after filtration i don't have any result

i try to do that


and i have an output

but for me i want to use

how can i solve this problem??!

Answer Source

You'll need to return the value from your function. :)

function filter($x) {
    // do the cleaning of your string
    return $y; 
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download