I want to know if I can make a PHP function like function john(), without having any parameters. Do PHP functions always have to have a parameter like john($action)?
My script below won't work because of my empty action. Do I have to pass a NULL value as a parameter?
funcs.php
function is_customer_logged_in() {
if($_COOKIE['HA_CUST_LOGIN'] == 1 && $_SESSION["loggedIn"]=="1"){
return true;
}else{
return false;
}
}
index.php
include("funcs.php");
if(is_customer_logged_in()) {
echo 'logged in';
} else {
echo 'not signed in';
}
login-form.php
/* pseudo code, if form details
match mySQL do this */
$_SESSION["loggedIn"]="1";
$_SESSION["userEmail"]=$username; //form variable
$_SESSION["userID"]=$username; //form variable
setcookie("HA_CUST_LOGIN", 1); // set a cookie and a session from a php salt db check
echo '<script type="text/javascript">window.location="index.php"</script>';
/* else go back to login-form.php */
Or do I have to return a string rather than a boolean?