PHP发布为空然后分配默认值[重复]

I have a search query that returns a results page that works great, if it receives data from the form. But if a user goes directly to the results page (they bookmarked the page) I want them to see all the results. The search is by day of the week and area . Can I default the day to the current day date("l") and the Area variable to Entire City? Code is below:

require("dbinfo.php");

$Area=$_POST['Area'];
$Day=$_POST['Day'];
$ID=$_POST['ID'];


include("History.php");
$con = mysql_connect('localhost', $username, $password );
if (!$con)
{
die('Could not connect: ' . mysql_error());
}
$db_selected = mysql_select_db($database, $con);
if (!$db_selected) {
die ('Can\'t use DB : ' . mysql_error());
}
$sql = "SELECT 
`ID`,`Name`,`Address`,`".$Day."`,`Area`,`PhoneNumber`,`logo`,`Website` FROM 
`JaxPlaces` WHERE (Area = '".$Area."' OR '".$Area."' = 'Entire City') and 
Status = 'active' and ".$Day." NOT LIKE 'NULL' ORDER BY Name;";
$result = mysql_query($sql);
if(!$result)
{

 }  
</div>

Use the null-coalescing operator in PHP7+

$Area = $_POST['Area'] ?? 'City';
$Day = $_POST['Day'] ?? date("l");

Use a ternary operator in PHP5:

$Area = isset($_POST['Area']) ? $_POST['Area'] : 'City';
$Day = isset($_POST['Day']) ? $_POST['Day'] : date("l");