[insert_php] // define variables and set to empty values $firstname=$middlename=$lastname = $address =$suburb=$city=$pincode=$mobileno =$landlineno=$nativeplace=$emailaddress=$occupation=$company=$designation=$maritalstatus=$noofchildren=$gender=$noofsibling= “”; $dateofbirth = date(“m-d-Y”); $fatherdateofbirth = date(“m-d-Y”); $motherdateofbirth = date(“m-d-Y”); $spousedateofbirth = date(“m-d-Y”); $child1dateofbirth = date(“m-d-Y”); $child2dateofbirth = date(“m-d-Y”); $child3dateofbirth = date(“m-d-Y”); $child4dateofbirth = date(“m-d-Y”); $child5dateofbirth = date(“m-d-Y”); $sibling1dateofbirth = date(“m-d-Y”); $sibling2dateofbirth = date(“m-d-Y”); $sibling3dateofbirth = date(“m-d-Y”); $sibling4dateofbirth = date(“m-d-Y”); $sibling5dateofbirth = date(“m-d-Y”); $fatherfirstname=$fathermiddlename=$fatherlastname=$fatheroccupation=$fathercompany=$fatherdesignation=$fathermobileno=””; $motherfirstname=$mothermiddlename=$motherlastname=$motheroccupation=$mothercompany=$motherdesignation=$mothermobileno=””; $spousefirstname=$spousemiddlename=$spouselastname=$spouseoccupation=$spousecompany=$spousedesignation=$spousemobileno=””; $child1firstname=$child1school=$child1stream=$child1occupation=$child1gender=””; $child2firstname=$child2school=$child2stream=$child2occupation=$child2gender=””; $child3firstname=$child3school=$child3stream=$child3occupation=$child3gender=””; $child4firstname=$child4school=$child4stream=$child4occupation=$child4gender=””; $child5firstname=$child5school=$child5stream=$child5occupation=$child5gender=””; $sibling1firstname=$sibling1middlename=$sibling1lastname=$sibling1occupation=$sibling1company=$sibling1designation=$sibling1mobileno=$sibling1gender=””; $sibling2firstname=$sibling2middlename=$sibling2lastname=$sibling2occupation=$sibling2company=$sibling2designation=$sibling2mobileno=$sibling2gender=””; $sibling3firstname=$sibling3middlename=$sibling3lastname=$sibling3occupation=$sibling3company=$sibling3designation=$sibling3mobileno=$sibling3gender=””; $sibling4firstname=$sibling4middlename=$sibling4lastname=$sibling4occupation=$sibling4company=$sibling4designation=$sibling4mobileno=$sibling4gender=””; $sibling5firstname=$sibling5middlename=$sibling5lastname=$sibling5occupation=$sibling5company=$sibling5designation=$sibling5mobileno=$sibling5gender=””; $maxid=””; global $wpdb; if ($_SERVER[“REQUEST_METHOD”] == “POST”) { $query = “SELECT MAX(id) FROM member”; $maxid = $wpdb->get_var($query); if (is_null($maxid)) { $maxid = 1; } else { $maxid = $maxid + 1; } $firstname = test_input($_POST[“firstname”]); $middlename = test_input($_POST[“middlename”]); $lastname = test_input($_POST[“lastname”]); $address = test_input($_POST[“address”]); $suburb = test_input($_POST[“suburb”]); $city = test_input($_POST[“city”]); $pincode = test_input($_POST[“pincode”]); $mobileno = test_input($_POST[“mobileno”]); $landlineno = test_input($_POST[“landlineno”]); $nativeplace = test_input($_POST[“nativeplace”]); $emailaddress = test_input($_POST[“emailaddress”]); $occupation = test_input($_POST[“occupation”]); $company = test_input($_POST[“company”]); $designation = test_input($_POST[“designation”]); $dateofbirth = test_input($_POST[“dateofbirth”]); $maritalstatus = test_input($_POST[“maritalstatus”]); $noofchildren = test_input($_POST[“noofchildren”]); $gender = test_input($_POST[“membergender”]); $noofsibling = test_input($_POST[“noofsibling”]); $fatherfirstname = test_input($_POST[“fatherfirstname”]); $fathermiddlename = test_input($_POST[“fathermiddlename”]); $fatherlastname = test_input($_POST[“fatherlastname”]); $fatheroccupation = test_input($_POST[“fatheroccupation”]); $fathercompany = test_input($_POST[“fathercompany”]); $fatherdesignation = test_input($_POST[“fatherdesignation”]); $fathermobileno = test_input($_POST[“fathermobileno”]); $fatherdateofbirth = test_input($_POST[“fatherdateofbirth”]); $motherfirstname = test_input($_POST[“motherfirstname”]); $mothermiddlename = test_input($_POST[“mothermiddlename”]); $motherlastname = test_input($_POST[“motherlastname”]); $motheroccupation = test_input($_POST[“motheroccupation”]); $mothercompany = test_input($_POST[“mothercompany”]); $motherdesignation = test_input($_POST[“motherdesignation”]); $mothermobileno = test_input($_POST[“mothermobileno”]); $motherdateofbirth = test_input($_POST[“motherdateofbirth”]); write_log(“New entry. Member Id:”.$maxid); write_log(“firstname :”.$firstname); write_log(“middlename :”.$middlename); write_log(“lastname :”.$lastname); write_log(“address :”.$address); write_log(“suburb :”.$suburb); write_log(“city :”.$city); write_log(“pincode :”.$pincode); write_log(“mobileno :”.$mobileno); write_log(“landlineno :”.$landlineno); write_log(“nativeplace :”.$nativeplace); write_log(“emailaddress :”.$emailaddress); write_log(“occupation :”.$occupation); write_log(“company :”.$company); write_log(“designation :”.$designation); write_log(“dateofbirth :”.$dateofbirth); write_log(“maritalstatus :”.$maritalstatus); write_log(“noofchildren :”.$noofchildren); write_log(“gender :”.$gender); write_log(“noofsibling :”.$noofsibling); write_log(“fatherfirstname :”.$fatherfirstname); write_log(“fathermiddlename :”.$fathermiddlename); write_log(“fatherlastname :”.$fatherlastname); write_log(“fatheroccupation :”.$fatheroccupation); write_log(“fathercompany :”.$fathercompany); write_log(“fatherdesignation :”.$fatherdesignation); write_log(“fathermobileno :”.$fathermobileno); write_log(“fatherdateofbirth :”.$fatherdateofbirth); write_log(“motherfirstname :”.$motherfirstname); write_log(“mothermiddlename :”.$mothermiddlename); write_log(“motherlastname :”.$motherlastname); write_log(“motheroccupation :”.$motheroccupation); write_log(“mothercompany :”.$mothercompany); write_log(“motherdesignation :”.$motherdesignation); write_log(“mothermobileno :”.$mothermobileno); write_log(“motherdateofbirth :”.$motherdateofbirth); if($maritalstatus == “Married”) { $spousefirstname = test_input($_POST[“spousefirstname”]); $spousemiddlename = test_input($_POST[“spousemiddlename”]); $spouselastname = test_input($_POST[“spouselastname”]); $spouseoccupation = test_input($_POST[“spouseoccupation”]); $spousecompany = test_input($_POST[“spousecompany”]); $spousedesignation = test_input($_POST[“spousedesignation”]); $spousemobileno = test_input($_POST[“spousemobileno”]); $spousedateofbirth = test_input($_POST[“spousedateofbirth”]); write_log(“spousefirstname :”.$spousefirstname); write_log(“spousemiddlename :”.$spousemiddlename); write_log(“spouselastname :”.$spouselastname); write_log(“spouseoccupation :”.$spouseoccupation); write_log(“spousecompany :”.$spousecompany); write_log(“spousedesignation :”.$spousedesignation); write_log(“spousemobileno :”.$spousemobileno); write_log(“spousedateofbirth :”.$spousedateofbirth); } if($noofsibling >= 1) { $sibling1firstname = test_input($_POST[“sibling1firstname”]); $sibling1middlename = test_input($_POST[“sibling1middlename”]); $sibling1lastname = test_input($_POST[“sibling1lastname”]); $sibling1occupation = test_input($_POST[“sibling1occupation”]); $sibling1company = test_input($_POST[“sibling1company”]); $sibling1designation = test_input($_POST[“sibling1designation”]); $sibling1gender = test_input($_POST[“sibling1gender”]); $sibling1mobileno = test_input($_POST[“sibling1mobileno”]); $sibling1dateofbirth = test_input($_POST[“sibling1dateofbirth”]); write_log(“sibling1firstname :”.$sibling1firstname); write_log(“sibling1middlename :”.$sibling1middlename); write_log(“sibling1lastname :”.$sibling1lastname); write_log(“sibling1occupation :”.$sibling1occupation); write_log(“sibling1company :”.$sibling1company); write_log(“sibling1designation :”.$sibling1designation); write_log(“sibling1gender :”.$sibling1gender); write_log(“sibling1mobileno :”.$sibling1mobileno); write_log(“sibling1dateofbirth :”.$sibling1dateofbirth); } if($noofsibling >= 2) { $sibling2firstname = test_input($_POST[“sibling2firstname”]); $sibling2middlename = test_input($_POST[“sibling2middlename”]); $sibling2lastname = test_input($_POST[“sibling2lastname”]); $sibling2occupation = test_input($_POST[“sibling2occupation”]); $sibling2company = test_input($_POST[“sibling2company”]); $sibling2designation = test_input($_POST[“sibling2designation”]); $sibling2gender = test_input($_POST[“sibling2gender”]); $sibling2mobileno = test_input($_POST[“sibling2mobileno”]); $sibling2dateofbirth = test_input($_POST[“sibling2dateofbirth”]); write_log(“sibling2firstname :”.$sibling2firstname); write_log(“sibling2middlename :”.$sibling2middlename); write_log(“sibling2lastname :”.$sibling2lastname); write_log(“sibling2occupation :”.$sibling2occupation); write_log(“sibling2company :”.$sibling2company); write_log(“sibling2designation :”.$sibling2designation); write_log(“sibling2gender :”.$sibling2gender); write_log(“sibling2mobileno :”.$sibling2mobileno); write_log(“sibling2dateofbirth :”.$sibling2dateofbirth); } if($noofsibling >= 3) { $sibling3firstname = test_input($_POST[“sibling3firstname”]); $sibling3middlename = test_input($_POST[“sibling3middlename”]); $sibling3lastname = test_input($_POST[“sibling3lastname”]); $sibling3occupation = test_input($_POST[“sibling3occupation”]); $sibling3company = test_input($_POST[“sibling3company”]); $sibling3designation = test_input($_POST[“sibling3designation”]); $sibling3gender = test_input($_POST[“sibling3gender”]); $sibling3mobileno = test_input($_POST[“sibling3mobileno”]); $sibling3dateofbirth = test_input($_POST[“sibling3dateofbirth”]); write_log(“sibling3firstname :”.$sibling3firstname); write_log(“sibling3middlename :”.$sibling3middlename); write_log(“sibling3lastname :”.$sibling3lastname); write_log(“sibling3occupation :”.$sibling3occupation); write_log(“sibling3company :”.$sibling3company); write_log(“sibling3designation :”.$sibling3designation); write_log(“sibling3gender :”.$sibling3gender); write_log(“sibling3mobileno :”.$sibling3mobileno); write_log(“sibling3dateofbirth :”.$sibling3dateofbirth); } if($noofsibling >= 4) { $sibling4firstname = test_input($_POST[“sibling4firstname”]); $sibling4middlename = test_input($_POST[“sibling4middlename”]); $sibling4lastname = test_input($_POST[“sibling4lastname”]); $sibling4occupation = test_input($_POST[“sibling4occupation”]); $sibling4company = test_input($_POST[“sibling4company”]); $sibling4designation = test_input($_POST[“sibling4designation”]); $sibling4gender = test_input($_POST[“sibling4gender”]); $sibling4mobileno = test_input($_POST[“sibling4mobileno”]); $sibling4dateofbirth = test_input($_POST[“sibling4dateofbirth”]); write_log(“sibling4firstname :”.$sibling4firstname); write_log(“sibling4middlename :”.$sibling4middlename); write_log(“sibling4lastname :”.$sibling4lastname); write_log(“sibling4occupation :”.$sibling4occupation) ; write_log(“sibling4company :”.$sibling4company); write_log(“sibling4designation :”.$sibling4designation); write_log(“sibling4gender :”.$sibling4gender); write_log(“sibling4mobileno :”.$sibling4mobileno); write_log(“sibling4dateofbirth :”.$sibling4dateofbirth); } if($noofsibling >= 5) { $sibling5firstname = test_input($_POST[“sibling5firstname”]); $sibling5middlename = test_input($_POST[“sibling5middlename”]); $sibling5lastname = test_input($_POST[“sibling5lastname”]); $sibling5occupation = test_input($_POST[“sibling5occupation”]); $sibling5company = test_input($_POST[“sibling5company”]); $sibling5designation = test_input($_POST[“sibling5designation”]); $sibling5gender = test_input($_POST[“sibling5gender”]); $sibling5mobileno = test_input($_POST[“sibling5mobileno”]); $sibling5dateofbirth = test_input($_POST[“sibling5dateofbirth”]); write_log(“sibling5firstname :”.$sibling5firstname); write_log(“sibling5middlename :”.$sibling5middlename); write_log(“sibling5lastname :”.$sibling5lastname); write_log(“sibling5occupation :”.$sibling5occupation) ; write_log(“sibling5company :”.$sibling5company); write_log(“sibling5designation :”.$sibling5designation); write_log(“sibling5gender :”.$sibling5gender); write_log(“sibling5mobileno :”.$sibling5mobileno); write_log(“sibling5dateofbirth :”.$sibling5dateofbirth); } if($noofchildren >= 1) { $child1firstname = test_input($_POST[“child1firstname”]); $child1school = test_input($_POST[“child1school”]); $child1stream = test_input($_POST[“child1stream”]); $child1gender = test_input($_POST[“child1gender”]); $child1dateofbirth = test_input($_POST[“child1dateofbirth”]); $child1occupation = test_input($_POST[“child1occupation”]); write_log(“child1firstname :”.$child1firstname); write_log(“child1school :”.$child1school); write_log(“child1stream :”.$child1stream); write_log(“child1gender :”.$child1gender); write_log(“child1occupation :”.$child1occupation); write_log(“child1dateofbirth :”.$child1dateofbirth); } if($noofchildren >= 2) { $child2firstname = test_input($_POST[“child2firstname”]); $child2school = test_input($_POST[“child2school”]); $child2stream = test_input($_POST[“child2stream”]); $child2gender = test_input($_POST[“child2gender”]); $child2dateofbirth = test_input($_POST[“child2dateofbirth”]); $child2occupation = test_input($_POST[“child2occupation”]); write_log(“child2firstname :”.$child2firstname); write_log(“child2school :”.$child2school); write_log(“child2stream :”.$child2stream); write_log(“child2gender :”.$child2gender); write_log(“child2occupation :”.$child2occupation); write_log(“child2dateofbirth :”.$child2dateofbirth); } if($noofchildren >=3) { $child3firstname = test_input($_POST[“child3firstname”]); $child3school = test_input($_POST[“child3school”]); $child3stream = test_input($_POST[“child3stream”]); $child3gender = test_input($_POST[“child3gender”]); $child3dateofbirth = test_input($_POST[“child3dateofbirth”]); $child3occupation = test_input($_POST[“child3occupation”]); write_log(“child3firstname :”.$child3firstname); write_log(“child3school :”.$child3school); write_log(“child3stream :”.$child3stream); write_log(“child3gender :”.$child3gender); write_log(“child3occupation :”.$child3occupation); write_log(“child3dateofbirth :”.$child3dateofbirth); } if($noofchildren >= 4) { $child4firstname = test_input($_POST[“child4firstname”]); $child4school = test_input($_POST[“child4school”]); $child4stream = test_input($_POST[“child4stream”]); $child4gender = test_input($_POST[“child4gender”]); $child4dateofbirth = test_input($_POST[“child4dateofbirth”]); $child4occupation = test_input($_POST[“child4occupation”]); write_log(“child4firstname :”.$child4firstname); write_log(“child4school :”.$child4school); write_log(“child4stream :”.$child4stream); write_log(“child4gender :”.$child4gender); write_log(“child4occupation :”.$child4occupation); write_log(“child4dateofbirth :”.$child4dateofbirth); } if($noofchildren >= 5) { $child5firstname = test_input($_POST[“child5firstname”]); $child5school = test_input($_POST[“child5school”]); $child5stream = test_input($_POST[“child5stream”]); $child5gender = test_input($_POST[“child5gender”]); $child5dateofbirth = test_input($_POST[“child5dateofbirth”]); $child5occupation = test_input($_POST[“child5occupation”]); write_log(“child5firstname :”.$child5firstname); write_log(“child5school :”.$child5school); write_log(“child5stream :”.$child5stream); write_log(“child5gender :”.$child5gender); write_log(“child5occupation :”.$child5occupation); write_log(“child5dateofbirth :”.$child5dateofbirth); } $existing_record = $wpdb->get_row( $wpdb->prepare( “SELECT * FROM member WHERE mobileno = %s”, $mobileno ) ); //if (!$existing_record) { $wpdb->insert( ‘member2’, array( ‘firstname’ => $firstname, ‘middlename’ => $middlename, ‘lastname’ => $lastname, ‘address’ => $address, ‘suburb’ => $suburb, ‘city’ => $city, ‘pincode’ => $pincode, ‘mobileno’ => $mobileno, ‘landlineno’ => $landlineno, ‘nativeplace’ => $nativeplace, ’emailaddress’ => $emailaddress, ‘occupation’ => $occupation, ‘company’ => $company, ‘designation’ => $designation, ‘dateofbirth’ => $dateofbirth, ‘maritalstatus’ => $maritalstatus, ‘noofchildren’ => $noofchildren, ‘gender’ => $gender, ‘noofsibling’ => $noofsibling, ‘id’ => $maxid ) ); //} else { // echo ““; // die; //} $wpdb->insert( ‘parent’, array( ‘firstname’ => $fatherfirstname, ‘middlename’ => $fathermiddlename, ‘lastname’ => $fatherlastname, ‘occupation’ => $fatheroccupation, ‘company’ => $fathercompany, ‘designation’ => $fatherdesignation, ‘mobileno’ => $fathermobileno, ‘dateofbirth’ => $fatherdateofbirth, ‘relation’ => ‘father’, ‘memberid’ => $maxid ) ); $wpdb->insert( ‘parent’, array( ‘firstname’ => $motherfirstname, ‘middlename’ => $mothermiddlename, ‘lastname’ => $motherlastname, ‘occupation’ => $motheroccupation, ‘company’ => $mothercompany, ‘designation’ => $motherdesignation, ‘mobileno’ => $mothermobileno, ‘dateofbirth’ => $motherdateofbirth, ‘relation’ => ‘mother’, ‘memberid’ => $maxid ) ); if($maritalstatus == “Married”) { $wpdb->insert( ‘spouse’, array( ‘firstname’ => $spousefirstname, ‘middlename’ => $spousemiddlename, ‘lastname’ => $spouselastname, ‘occupation’ => $spouseoccupation, ‘company’ => $spousecompany, ‘designation’ => $spousedesignation, ‘mobileno’ => $spousemobileno, ‘dateofbirth’ => $spousedateofbirth, ‘memberid’ => $maxid ) ); } if($noofsibling >= 1) { $wpdb->insert( ‘sibling’, array( ‘firstname’ => $sibling1firstname, ‘middlename’ => $sibling1middlename, ‘lastname’ => $sibling1lastname, ‘occupation’ => $sibling1occupation, ‘company’ => $sibling1company, ‘designation’ => $sibling1designation, ‘mobileno’ => $sibling1mobileno, ‘dateofbirth’ => $sibling1dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $sibling1gender ) ); } if($noofsibling >= 2) { $wpdb->insert( ‘sibling’, array( ‘firstname’ => $sibling2firstname, ‘middlename’ => $sibling2middlename, ‘lastname’ => $sibling2lastname, ‘occupation’ => $sibling2occupation, ‘company’ => $sibling2company, ‘designation’ => $sibling2designation, ‘mobileno’ => $sibling2mobileno, ‘dateofbirth’ => $sibling2dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $sibling2gender ) ); } if($noofsibling >= 3) { $wpdb->insert( ‘sibling’, array( ‘firstname’ => $sibling3firstname, ‘middlename’ => $sibling3middlename, ‘lastname’ => $sibling3lastname, ‘occupation’ => $sibling3occupation, ‘company’ => $sibling3company, ‘designation’ => $sibling3designation, ‘mobileno’ => $sibling3mobileno, ‘dateofbirth’ => $sibling3dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $sibling3gender ) ); } if($noofsibling >= 4) { $wpdb->insert( ‘sibling’, array( ‘firstname’ => $sibling4firstname, ‘middlename’ => $sibling4middlename, ‘lastname’ => $sibling4lastname, ‘occupation’ => $sibling4occupation, ‘company’ => $sibling4company, ‘designation’ => $sibling4designation, ‘mobileno’ => $sibling4mobileno, ‘dateofbirth’ => $sibling4dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $sibling4gender ) ); } if($noofsibling >= 5) { $wpdb->insert( ‘sibling’, array( ‘firstname’ => $sibling5firstname, ‘middlename’ => $sibling5middlename, ‘lastname’ => $sibling5lastname, ‘occupation’ => $sibling5occupation, ‘company’ => $sibling5company, ‘designation’ => $sibling5designation, ‘mobileno’ => $sibling5mobileno, ‘dateofbirth’ => $sibling5dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $sibling5gender ) ); } if($noofchildren >= 1) { $wpdb->insert( ‘children’, array( ‘firstname’ => $child1firstname, ‘occupation’ => $child1occupation, ‘school’ => $child1school, ‘stream’ => $child1stream, ‘dateofbirth’ => $child1dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $child1gender ) ); } if($noofchildren >= 2) { $wpdb->insert( ‘children’, array( ‘firstname’ => $child2firstname, ‘occupation’ => $child2occupation, ‘school’ => $child2school, ‘stream’ => $child2stream, ‘dateofbirth’ => $child2dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $child2gender ) ); } if($noofchildren >= 3) { $wpdb->insert( ‘children’, array( ‘firstname’ => $child3firstname, ‘occupation’ => $child3occupation, ‘school’ => $child3school, ‘stream’ => $child3stream, ‘dateofbirth’ => $child3dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $child3gender ) ); } if($noofchildren >= 4) { $wpdb->insert( ‘children’, array( ‘firstname’ => $child4firstname, ‘occupation’ => $child4occupation, ‘school’ => $child4school, ‘stream’ => $child4stream, ‘dateofbirth’ => $child4dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $child4gender ) ); } if($noofchildren >= 5) { $wpdb->insert( ‘children’, array( ‘firstname’ => $child5firstname, ‘occupation’ => $child5occupation, ‘school’ => $child5school, ‘stream’ => $child5stream, ‘dateofbirth’ => $child5dateofbirth, ‘memberid’ => $maxid, ‘gender’ => $child5gender ) ); } echo ““; } // $telephone = test_input($_POST[“telephone”]); // $address = test_input($_POST[“address”]); // if($wpdb->insert( // ‘Test’, // array( // ‘name’ => $fname, // ‘tel’ => $telephone, // ‘address’ => $address // ) // )==false) // { // wp_die(“Database insertion failed”); // } // else // { // echo ““; // } function test_input($data) { $data = trim($data); $data = stripslashes($data); $data = htmlspecialchars($data); return $data; } [/insert_php]