I have this part of code

<?php 
$showmonth=$_POST['showmonth'];
$showyear=$_POST['showyear'];
$showmonth=preg_replace('#[^0-9]#i','',$showmonth);
$showyear=preg_replace('#[^0-9]#i','',$showyear);

$day_count=cal_days_in_month(CAL_GREGORIAN,$showmonth,$showyear);
$pre_days=date('w',mktime(0,0,0,$showmonth,1,$showyear));
$post_days=(6-(date('w',mktime(0,0,0,$showmonth,$day_count,$showyear))));

but i get errors like undefined index showyear,and errors on cal_days_in_month parameter 3 expected to be long, and also mktime parameter 6 expected to be long all due to the undefined index, how do i fix it?

My suggestion:

<?php 
$showmonth=(int)$_POST['showmonth'];
$showyear=(int)$_POST['showyear'];
$showmonth=preg_replace('#[^0-9]#i','',$showmonth);
$showyear=preg_replace('#[^0-9]#i','',$showyear);

$day_count=cal_days_in_month(CAL_GREGORIAN,$showmonth,$showyear);
$pre_days=date('w',mktime(0,0,0,$showmonth,1,$showyear));
$post_days=(6-(date('w',mktime(0,0,0,$showmonth,$day_count,$showyear))));

When you POST something, PHP thinks always it is a string. So you are mixing numbers with strings and that in any program language is always a bad idea.