global $wpdb;
$errors =array();
$blnUploadImage = false;
if(isset($_FILES[‘profile_pic’]) && !empty($_FILES[‘profile_pic’][‘tmp_name’])){
$blnUploadImage = true;
$file_size =$_FILES[‘profile_pic’][‘size’];
$file_tmp =$_FILES[‘profile_pic’][‘tmp_name’];
$file_type=$_FILES[‘profile_pic’][‘type’];
$file_ext=strtolower(end(explode(‘.’,$_FILES[‘profile_pic’][‘name’])));
$expensions= array(“jpeg”,”jpg”,”png”,”JPEG”,”JPG”,”PNG”);
if(in_array($file_ext,$expensions)=== false){
$errors[]=”Profile picture should be image(JPEG or PNG file).”;
$blnUploadImage = false;
}
if($file_size > 2097152){
$errors[]=’Profile picture should not be more than 2 MB’;
$blnUploadImage = false;
}
}
if(isset($_POST) && !empty($_POST) && empty($errors))
{
$results = $wpdb->get_results( “SELECT * FROM wp_members where email = ‘”.$_POST[’email’].”‘ or mob_number ='”.$_POST[‘mob_number’].”‘ “);
if(count($results)> 0)
{
$errors[] = “Please provide unique email address and/ or mobile no.”;
}
if(empty($errors))
{
$arrDOB = split(“/”,$_POST[‘dob’]);
$strDOB = $arrDOB[2].”-“.$arrDOB[1].”-“.$arrDOB[0];
$arrDOB1 = split(“/”,$_POST[‘family_dob1’]);
if(count($arrDOB1) == 3)
{
$strDOB1 = $arrDOB1[2].”-“.$arrDOB1[1].”-“.$arrDOB1[0];
}
else
{
$strDOB1 = “0000-00-00”;
}
$arrDOB2 = split(“/”,$_POST[‘family_dob2’]);
if(count($arrDOB2) == 3)
{
$strDOB2 = $arrDOB2[2].”-“.$arrDOB2[1].”-“.$arrDOB2[0];
}
else
{
$strDOB2 = “0000-00-00”;
}
$arrDOB3 = split(“/”,$_POST[‘family_dob3’]);
if(count($arrDOB3) == 3)
{
$strDOB3 = $arrDOB3[2].”-“.$arrDOB3[1].”-“.$arrDOB3[0];
}
else
{
$strDOB3 = “0000-00-00”;
}
$arrDOB4 = split(“/”,$_POST[‘family_dob4’]);
if(count($arrDOB4) == 3)
{
$strDOB4 = $arrDOB4[2].”-“.$arrDOB4[1].”-“.$arrDOB4[0];
}
else
{
$strDOB4 = “0000-00-00”;
}
$arrDOB5 = split(“/”,$_POST[‘family_dob5’]);
if(count($arrDOB5) == 3)
{
$strDOB5 = $arrDOB5[2].”-“.$arrDOB5[1].”-“.$arrDOB5[0];
}
else
{
$strDOB5 = “0000-00-00”;
}
$qry = “insert into wp_members (fname,mname,lname,ffname,fmname,flname,dob,gender,blood_group,marital_status,gotra,caste,sub_caste,qualification,company_name,
company_address,designation,mob_number,landline,email,address,city,state,country,pincode,native_address,type_membership,family_name1 ,family_dob1,family_rel1,family_bg1,family_name2,family_dob2,family_rel2,family_bg2,family_name3,family_dob3,family_rel3,family_bg3,family_name4,family_dob4,family_rel4, family_bg4,family_name5,family_dob5,family_rel5,family_bg5,family_qualification1,family_qualification2,family_qualification3,family_qualification4,family_qualification5,profile_pic,username,password,status,created,updated) values (‘”.DBVarConv($_POST[‘fname’]).”‘,'”.DBVarConv($_POST[‘mname’]).”‘,'”.DBVarConv($_POST[‘lname’]).”‘,'”.DBVarConv($_POST[‘ffname’]).”‘,'”.DBVarConv($_POST[‘fmname’]).”‘,'”.DBVarConv($_POST[‘flname’]).”‘,'”.$strDOB.”‘,'”.DBVarConv($_POST[‘gender’]).”‘,'”.DBVarConv($_POST[‘blood_group’]).”‘,'”.DBVarConv($_POST[‘marital_status’]).”‘,'”.DBVarConv($_POST[‘gotra’]).”‘,'”.DBVarConv($_POST[‘caste’]).”‘,'”.DBVarConv($_POST[‘sub_caste’]).”‘,'”.DBVarConv($_POST[‘qualification’]).”‘,'”.DBVarConv($_POST[‘company_name’]).”‘,'”.DBVarConv($_POST[‘company_address’]).”‘,'”.DBVarConv($_POST[‘designation’]).”‘,'”.DBVarConv($_POST[‘mob_number’]).”‘,'”.DBVarConv($_POST[‘landline’]).”‘,'”.DBVarConv($_POST[’email’]).”‘,'”.DBVarConv($_POST[‘address’]).”‘,'”.DBVarConv($_POST[‘city’]).”‘,'”.DBVarConv($_POST[‘state’]).”‘,'”.DBVarConv($_POST[‘country’]).”‘,'”.DBVarConv($_POST[‘pincode’]).”‘,'”.DBVarConv($_POST[‘na_address’]).”‘,'”.DBVarConv($_POST[‘type_membership’]).”‘,'”.DBVarConv($_POST[‘family_name1’]).”‘,'”.$strDOB1.”‘,'”.DBVarConv($_POST[‘family_rel1’]).”‘,'”.DBVarConv($_POST[‘family_bg1’]).”‘,'”.DBVarConv($_POST[‘family_name2’]).”‘,'”.$strDOB2.”‘,'”.DBVarConv($_POST[‘family_rel2’]).”‘,'”.DBVarConv($_POST[‘family_bg2’]).”‘,'”.DBVarConv($_POST[‘family_name3’]).”‘,'”.$strDOB3.”‘,'”.DBVarConv($_POST[‘family_rel3’]).”‘,'”.DBVarConv($_POST[‘family_bg3’]).”‘,'”.DBVarConv($_POST[‘family_name4’]).”‘,'”.$strDOB4.”‘,'”.DBVarConv($_POST[‘family_rel4’]).”‘,'”.DBVarConv($_POST[‘family_bg4’]).”‘,'”.DBVarConv($_POST[‘family_name5’]).”‘,'”.$strDOB5.”‘,'”.DBVarConv($_POST[‘family_rel5’]).”‘,'”.DBVarConv($_POST[‘family_bg5’]).”‘,'”.DBVarConv($_POST[‘qualification1’]).”‘,'”.DBVarConv($_POST[‘qualification2’]).”‘,'”.DBVarConv($_POST[‘qualification3’]).”‘,'”.DBVarConv($_POST[‘qualification4’]).”‘,'”.DBVarConv($_POST[‘qualification5’]).”‘,”,”,”,’New’,'”.date(“Y-m-d”).”‘,'”.date(“Y-m-d”).”‘)”;
/*echo $qry;
die;*/
$member_reg = $wpdb->query( $qry );
$file_name = “”;
if($blnUploadImage){
$file_name = $wpdb->insert_id.”.”.$file_ext;
//move_uploaded_file($file_tmp,”wp-content/uploads/member/profile_pic/”.$file_name);
if(!move_uploaded_file($file_tmp,”wp-content/uploads/member/profile_pic/”.$file_name)){
$file_name = “”;
}
}
$username = str_pad($wpdb->insert_id, 5, “0”, STR_PAD_LEFT);
$update_query = “UPDATE wp_members SET username=’CGIF”.$username .”‘, password = ‘”.md5($_POST[‘mob_number’]).”‘,profile_pic = ‘”.$file_name.”‘ WHERE ID='”.$wpdb->insert_id.”‘”;
$member_reg = $wpdb->query( $update_query);
//$headers[] = ‘From: CGIF Admin
wp_mail( $_POST[’email’], “CGIF Member Registration”, “We have received your request for membership. You will receive an approval email soon.”);
wp_mail(“dharmdipgadhvi88@gmail.com,admin@cgif.org.in”, “CGIF Member Registration”, “New Member Registration Received\nMember Id: “.$wpdb->insert_id );
/*wp_mail(“dharmdipgadhvi88@gmail.com”, “CGIF Member Registration”, “New Member Registration Received\nMember Id: “.$wpdb->insert_id );*/
wp_redirect(“http://cgif.org.in/index.php/thank-you-for-registration/”);
exit;
}
}
echo “
‘;
[/insert_php]