-2

form.php

<form method="POST" target='_blank' action='CF.php' id="cf" name="cf">
    <input type='text' id='test' name='test' value='0' > 
    <button form="cf">Proses</button> 

cf.php

if ($_SERVER["REQUEST_METHOD"] == "POST") {
$test = $_POST['test']; 
if (empty($test)) {
    echo "test is empty";
  } else {
    echo $test;
  }
echo "connect";
}else{
    echo "error";
}
?>

result is "test is empty connect"

did I do a little wrong ? or big wrong ? T.T

deceze
  • 510,633
  • 85
  • 743
  • 889

2 Answers2

1

You have to consider that empty('0') is equal to true. See docs here

KmoSkillz
  • 169
  • 1
  • 9
-1

follow this instruction.

<form method="POST" action='CF.php'>
    <input type='text' id='test' name='test' value='test' >
    <button type="submit">Proses</button>
</form>
SmR
  • 22
  • 5