Reputation: 21
Is it possible to tell whether the Post is just Empty, or Just hasn't been posted yet? I know
if($_POST['varible']!="") {
$loginerr="";
} else {
$loginerr="Please check your entry.";
}
or
if(ifempty($_POST['varible']) {
$loginerr="Please Check your Entry.";
} else {
$loginerr="";
}
I just want a way, to tell whether the $_POST has been sent or not.
Upvotes: 1
Views: 80
Reputation: 4110
<?php
//save it in a variable
$variable = $_POST['variable'];
//now check
if(empty($variable )) {
echo "The field was empty";
}
else
{
//whatever you want
}
?>
Upvotes: 0
Reputation: 1481
PHP isset is used for checking the row exist in array. empty is used for checking the array value. So here we can use this two in if condition is better.
if(isset($_POST['vaiable']) && !empty($_POST['vaiable'])){
//Here all the condition is satisfied and the $_POST['vaiable'] definitely have some value
}
Upvotes: 2
Reputation: 45
the syntax to check is
if(isset($_POST['vaiable'])){code goes here}
to check post is empty or not you can check by following syntax
If(empty($_POST['vaiable'])){code goes here}
if(!empty($_POST['varible'])) {
$loginerr="";
} else {
$loginerr="Please check your entry.";
}
Upvotes: 1
Reputation: 3228
$loginErr='';
if (!isset($_POST['variable']))
$loginerr="Please Check your Entry.";
Upvotes: 2
Reputation: 4820
Use the empty
function in PHP
if(empty($_POST['varible'])) {
$loginerr = "Please Check your Entry.";
} else {
$loginerr = "";
}
OR the isset
function
if(!isset($_POST['varible'])) {
$loginerr = "Please Check your Entry.";
} else {
$loginerr = "";
}
Upvotes: 0
Reputation: 888
Try this code
if(empty($_POST['varible']))
{
$loginerr="Please Check your Entry.";
}
else
{
$loginerr = "";
}
Upvotes: 0