I’m trying to do a server-side validation of the date chosen by user and the current date and here’s what I have:
$day = $_POST['day'];
$month = $_POST['month'];
$year = $_POST['year'];
$dateval = $year + $month + $day;
if ($dateval - $today < 0) {
$datepassed = 'no';
}
else {
$datepassed = 'yes';
}
Now as far as I know, everything is working flawlessly except the fact that the $dateval variable just adds up all the numbers instead of putting them together to form the date chosen by the user. for example 20110719 returns 2037. How can I make a veriable that combines the numbers without adding them? Any help is appreciated.
If you’re concatenating strings, you should be using the concatenation operator,
.:Otherwise, PHP will be clever and convert your strings to integers, a consequence of weak typing as implemented by the PHP language.