In PHP is this enough to guarantee a form has been submitted by clicking the form submit button and to verify the content posted is not empty?
if($_SERVER['REQUEST_METHOD']=='POST' && !empty($_POST['field_data']))
{
echo "ok";
}
In PHP is this enough to guarantee a form has been submitted by clicking the form submit button and to verify the content posted is not empty?
if($_SERVER['REQUEST_METHOD']=='POST' && !empty($_POST['field_data']))
{
echo "ok";
}
I think, there may be a way to be sure the form was submitted using your form.
If I would like to do it, I think I will make something like this :
$secure = $_SESSION['form']['submit'] = MD5(time());
<form>
<input type='hidden' name='secure_form' value='<?php echo $secure ?>' />
</form>
And else when submitted check the value :
if($_SERVER['REQUEST_METHOD']=='POST' && isset($_POST['secure_form']) && $_SESSION['form']['submit'] == $_POST['secure_form']) {
//do stuff
}
Of course, you have to add session_start()
at the top of the page!