//no cache
header("Cache-control: private, no-cache");
header("Expires: Mon, 26 Jul 1997 05:00:00 GMT");
header("Pragma: no-cache");
require "incs/mem.obj.php";
$mbr=new users(1);
if($mbr->log_sts<1){header("Location: log_in.html?frm=profile.html");exit;}
if($_POST['Update']){
for($xx=0;$xx<1;$xx++){
foreach($_POST as $k => $v){
${$k}=addslashes(preg_replace("/[^a-z0-9\s'#&@_.!-]/i","",$v));
if(!${$k}){
if($k!="info")$mbr->err[$k]=1;
}
else{$_POST[$k]=${$k};}
}
if(count($mbr->err)){$mbr->err_mess="Please complete the areas indicated in red";break;}
if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $_POST['email'])){$mbr->err_mess="Please enter a valid email address";$mbr->err["email"]=1;break;}
if(!checkdate($_POST['m1'],$_POST['d1'],$_POST['y1'])){
$mbr->err_mess="Please enter a valid start of service date";$mbr->err["served"]=1;break;
}
if(!checkdate($_POST['m2'],$_POST['d2'],$_POST['y2'])){
$mbr->err_mess="Please enter a valid end of service date";$mbr->err["served"]=1;break;
}
//echo date("Ymd")." ".$_POST['year'].$_POST['month'].$_POST['day'];
$sdate1=$_POST['y1']."-".$_POST['m1']."-".$_POST['d1'];
$sdate2=$_POST['y2']."-".$_POST['m2']."-".$_POST['d2'];
if($sdate1>=$sdate2){
$mbr->err_mess="Please a valid range of service dates";$mbr->err["served"]=1;break;
}
if(!$_POST['opt_add'])$opt_add=2;else $opt_add=1;
if(!$_POST['opt_phn'])$opt_phn=2;else $opt_phn=1;
if(!$_POST['opt_eml'])$opt_eml=2;else $opt_eml=1;
$sql="update users set first_name='$first_name',last_name='$last_name',address='$address',city='$city',state='$state',zip='$zip',phone='$phone',email='$email',sdate1='$sdate1',sdate2='$sdate2',opt_add=$opt_add,opt_phn=$opt_phn,opt_eml=$opt_eml,info='$info' where userID='".$mbr->userID."'";
$result=mysql_query($sql);
if($result)$mbr->err_mess="Your profile has been successfully updated";
else $mbr->err_mess="Error: Your profile could not be updated";
}
}
if(!count($mbr->err)){
$sql="select *,opt_add+0 as opt_adx,opt_eml+0 as opt_emx,opt_phn+0 as opt_phx from users where userID='".$mbr->userID."'";
$result=mysql_query($sql);
$row=mysql_fetch_assoc($result);
foreach($row as $k => $v)${$k}=$v;
$tmp=explode("-",$sdate1);
$m1=$tmp[1];
$d1=$tmp[2];
$y1=$tmp[0];
$tmp=explode("-",$sdate2);
$m2=$tmp[1];
$d2=$tmp[2];
$y2=$tmp[0];
}
else{
foreach($_POST as $k => $v)${$k}=stripslashes($v);
}
?>