function DBVarConv($var)
{
return addslashes(html_entity_decode($var,ENT_COMPAT,’UTF-8′));
}
global $wpdb;
$errors =array();
if(isset($_POST) && !empty($_POST) && empty($errors))
{
$member_id = ”;
if(isset($_SESSION[‘ID’]) && isset($_SESSION[‘USERNAME’]) && !empty($_SESSION[‘ID’]) && !empty($_SESSION[‘USERNAME’]))
{
$member_id = $_SESSION[‘ID’];
}
else if(!empty($_POST[‘username’]) && !empty($_POST[‘password’]))
{
$results = $wpdb->get_results( “SELECT ID FROM wp_members where username = ‘”.DBVarConv($_POST[‘username’]).”‘ and password = ‘”.md5($_POST[‘password’]).”‘ “);
//echo “SELECT ID FROM wp_members where username = ‘”.$username.”‘ and password = ‘”.md5($_POST[‘password’]).”‘ “;
if(count($results) > 0)
{
$member_id = $results[0]->ID;
}
else
{
$errors[]= “Please provide correct membership login details”;
}
}
$blnUploadImage = false;
if(!empty($member_id))
{
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(empty($errors))
{
$arrDOB = split(“/”,$_POST[‘dob’]);
$strDOB = $arrDOB[2].”-“.$arrDOB[1].”-“.$arrDOB[0];
//$arrBTime = split(“:”,);
$strBTime = $_POST[‘birth_time’];
$qry = “insert into wp_matrimony (member_id,profile,fname,mname,lname,dob,birth_time,gender,marital_status,mothername,language1,language2,language3,gotra,
caste,sub_caste,qualification,company_name,designation,company_address,address,city,state,country,pincode,mob_number,landline,email,native_address,hobbies,about_me,looking_for,created,updated) values (‘”.DBVarConv($member_id).”‘,'”.DBVarConv($_POST[‘profile_for’]).”‘,'”.DBVarConv($_POST[‘fname’]).”‘,'”.DBVarConv($_POST[‘mname’]).”‘,'”.DBVarConv($_POST[‘lname’]).”‘,'”.$strDOB.”‘,'”.$strBTime.”‘,'”.DBVarConv($_POST[‘gender’]).”‘,'”.DBVarConv($_POST[‘marital_status’]).”‘,'”.DBVarConv($_POST[‘mother_name’]).”‘,'”.DBVarConv($_POST[‘language1’]).”‘,'”.DBVarConv($_POST[‘language2’]).”‘,'”.DBVarConv($_POST[‘language3’]).”‘,'”.DBVarConv($_POST[‘gotra’]).”‘,'”.DBVarConv($_POST[‘caste’]).”‘,'”.DBVarConv($_POST[‘sub_caste’]).”‘,'”.DBVarConv($_POST[‘qualification’]).”‘,'”.DBVarConv($_POST[‘company_name’]).”‘,'”.DBVarConv($_POST[‘designation’]).”‘,'”.DBVarConv($_POST[‘company_address’]).”‘,'”.DBVarConv($_POST[‘address’]).”‘,'”.DBVarConv($_POST[‘city’]).”‘,'”.DBVarConv($_POST[‘state’]).”‘,'”.DBVarConv($_POST[‘country’]).”‘,'”.DBVarConv($_POST[‘pincode’]).”‘,'”.DBVarConv($_POST[‘mob_number’]).”‘,'”.DBVarConv($_POST[‘landline’]).”‘,'”.DBVarConv($_POST[’email’]).”‘,'”.DBVarConv($_POST[‘na_address’]).”‘,'”.DBVarConv($_POST[‘hobbies’]).”‘,'”.DBVarConv($_POST[‘about_me’]).”‘,'”.DBVarConv($_POST[‘looking_for’]).”‘,'”.date(“Y-m-d”).”‘,'”.date(“Y-m-d”).”‘)”;
$matrimony_reg = $wpdb->query( $qry );
$file_name = “”;
if($blnUploadImage){
$file_name = $wpdb->insert_id.”-“.$member_id.”.”.$file_ext;
//move_uploaded_file($file_tmp,”wp-content/uploads/member/matrimony/”.$file_name);
if(!move_uploaded_file($file_tmp,”wp-content/uploads/member/matrimony/”.$file_name)){
$file_name = “”;
}
$username = str_pad($wpdb->insert_id, 5, “0”, STR_PAD_LEFT);
$update_query = “UPDATE wp_matrimony SET profile_pic='”.$file_name.”‘ WHERE ID='”.$wpdb->insert_id.”‘”;
$member_reg = $wpdb->query( $update_query);
}
//redirect to thank you page…
wp_mail(“dharmdipgadhvi88@gmail.com,admin@cgif.org.in”, “CGIF Matrimonial Registration”, “New Matrimonial Registration Received\nMember Id: “.$member_id );
wp_redirect(“http://cgif.org.in/index.php/thank-you-for-registration/?matrimony=1”);
}
$profile_for= $_POST[‘profile_for’];
$fname= $_POST[‘fname’];
$mname= $_POST[‘mname’];
$lname= $_POST[‘lname’];
$profile_pic= $_POST[‘profile_pic’];
$dob= $_POST[‘dob’];
$birth_time= $_POST[‘birth_time’];
$gender= $_POST[‘gender’];
$marital_status= $_POST[‘marital_status’];
$mother_name= $_POST[‘mother_name’];
$language1= $_POST[‘language1’];
$language2= $_POST[‘language2’];
$language3= $_POST[‘language3’];
$gotra= $_POST[‘gotra’];
$caste= $_POST[‘caste’];
$sub_caste= $_POST[‘sub_caste’];
$qualification= $_POST[‘qualification’];
$company_name= $_POST[‘company_name’];
$designation= $_POST[‘designation’];
$company_address= $_POST[‘company_address’];
$address= $_POST[‘address’];
$company_address= $_POST[‘company_address’];
$city= $_POST[‘city’];
$state= $_POST[‘state’];
$country= $_POST[‘country’];
$pincode= $_POST[‘pincode’];
$mob_number= $_POST[‘mob_number’];
$landline= $_POST[‘landline’];
$email= $_POST[’email’];
$na_address= $_POST[‘na_address’];
$hobbies= $_POST[‘hobbies’];
$about_me= $_POST[‘about_me’];
$looking_for= $_POST[‘looking_for’];
$username= $_POST[‘username’];
$password= $_POST[‘password’];
}
else if(!empty($_SESSION[‘ID’]) && !empty($_SESSION[‘USERNAME’]) && !empty($_SESSION[‘FNAME’]))
{
//echo “2”;
$results = $wpdb->get_results( “SELECT * FROM wp_members where username = ‘”.DBVarConv($_SESSION[‘USERNAME’]).”‘ and fname= ‘”.DBVarConv($_SESSION[‘FNAME’]).”‘ and ID = ‘”.$_SESSION[‘ID’].”‘ “);
if(count($results) > 0)
{
//print_r($results);
$fname= $results[0]->fname;
$mname= $results[0]->mname;
$lname= $results[0]->lname;
$gender= $results[0]->gender;
//$dob= $results[0]->dob;
$marital_status= $results[0]->marital_status;
$gotra= $results[0]->gotra;
$caste= $results[0]->caste;
$sub_caste= $results[0]->sub_caste;
$qualification= $results[0]->qualification;
$company_name= $results[0]->company_name;
$designation= $results[0]->designation;
$company_address= $results[0]->company_address;
$address= $results[0]->address;
$city= $results[0]->city;
$state= $results[0]->state;
$country= $results[0]->country;
$pincode= $results[0]->pincode;
$mob_number= $results[0]->mob_number;
$landline= $results[0]->landline;
$email= $results[0]->email;
$na_address= $results[0]->native_address;
$username = $results[0]->username;
$password = “test”;
}
}
echo ”
‘;
[/insert_php]