Reload Gym

[private]

Reload Gym after create gym account completed.


[insert_php]
include ‘mail.php’; // function send E-mail.

/* ————————————————-
Update status after Register.
1 = Gym
2 = Individual
3 = NF
4 = Guest
5 = Admin (Manual Set)
————————————————–*/

$count_user = mysql_query(“SELECT `ID` FROM `imaesdbusers`”);
$rowcount = mysql_num_rows($count_user);
mysql_free_result($count_user);

$end_user = mysql_query(“SELECT MAX(`ID`) AS max_id FROM `imaesdbusers`”);
$max_id = mysql_fetch_assoc($end_user);
mysql_free_result($end_user);

$sql_update = ‘UPDATE `Update` SET `Count` = ‘.$rowcount.’, `End` = ‘.$max_id[max_id].’ WHERE `ID` = 1′;// Update ‘count’ in Update Table.

if (!(mysql_query($sql_update))){echo “Update Error
“;}

$query_update = mysql_query(“SELECT * FROM `Update`”);
$result_update = mysql_fetch_assoc($query_update);
//echo $result_update[Last_Update].”,”.$result_update[End].”,”.$result_update[Count].”
“;

$last_update = $result_update[Last_Update];
$end = $result_update[End];
$count = $result_update[Count];

while($last_update < $end){ $last_update = $last_update + 1; $query_check = mysql_query('SELECT * FROM `imaesdbusers` WHERE `ID`= "'.$last_update.'"'); $status = mysql_fetch_assoc($query_check); mysql_free_result($query_check); if($status[ID] != ""){ if($status[user_status_register] == 0){ $query_type = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_gender"'); $user_type = mysql_fetch_assoc($query_type); $query_country = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_id_country"'); $query_data = mysql_fetch_assoc($query_country); $ID_country = $query_data[meta_value]; $query_country_name = mysql_query('SELECT `name` FROM `imaesdbmgm_countries` WHERE `Code3`= "'.$ID_country.'"'); $query_birthdate = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_birthdate"'); $query_address = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_address"'); $query_city = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_city"'); $query_zip = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_zip"'); $query_phone = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_phone"'); $query_email = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_email"'); $query_gym_name = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_gym_name"'); $query_gym_code = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_gym_code"'); $query_first_name = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_first_name"'); $query_last_name = mysql_query('SELECT `meta_value` FROM `imaesdbusermeta` WHERE `user_id` = "'.$last_update.'" AND `meta_key` = "_mgm_cf_last_name"'); $query_data = mysql_fetch_assoc($query_country_name); $name_country = $query_data[name]; $query_data = mysql_fetch_assoc($query_birthdate); $user_birthdate = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_address); $user_address = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_city); $user_city = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_zip); $user_zip = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_phone); $user_phone = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_email); $user_email = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_gym_name); $user_gym_name = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_gym_code); $user_gym_code = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_first_name); $user_first_name = $query_data[meta_value]; $query_data = mysql_fetch_assoc($query_last_name); $user_last_name = $query_data[meta_value]; if ($user_city != "###"){ $user_address = $user_address." ".$user_city." ".$user_zip; } if($user_type[meta_value] == "Gym"){ $check_country = mysql_query('SELECT `List_Number` FROM `NF` WHERE `Code3`= "'.$ID_country.'"'); $count_country = mysql_num_rows($check_country); if ($count_country == 0){ $sql = 'INSERT INTO `NO_NF`(`User_ID`, `Country`, `Code3`, `Establish`, `Address`, `Tel`, `Email`, `Gym_member_is_No_NF`, `Short_code_gym`, `first_name`, `last_name`) VALUES ("'.$last_update.'","'.$name_country.'","'.$ID_country.'","'.$user_birthdate.'","'.$user_address.'","'.$user_phone.'","'.$user_email.'","'.$user_gym_name.'","'.$user_gym_code.'","'.$user_first_name.'","'.$user_last_name.'")'; if (!(mysql_query($sql))) {echo "New record created Error";} $sql_last_update = 'UPDATE `Update` SET `Last_Update` = "'.$last_update.'" WHERE `ID` = 1'; // Update New value of Last_Update in Update table if (!(mysql_query($sql_last_update))){echo "
Update Last Update Error
“;}

$sql_status_update = ‘UPDATE `imaesdbusers` SET `user_status_register`= “1” WHERE `ID` = ‘.$last_update; // Update New value of Last_Update in Update table
if (!(mysql_query($sql_status_update))){echo “
Update Status Error
“;}

}
else{
$sql = ‘INSERT INTO `NF_Member`(`User_ID`, `NF_Code3`, `Gym_name`, `Gym_ID`, `Gym_Establish`, `Gym_Fname`, `Gym_Lname`, `Gym_Email`, `Gym_Tel`, `Gym_Address`)
VALUES (“‘.$last_update.’”,”‘.$ID_country.’”,”‘.$user_gym_name.’”,”‘.$user_gym_code.’”,”‘.$user_birthdate.’”,”‘.$user_first_name.’”,”‘.$user_last_name.’”,”‘.$user_email.’”,”‘.$user_phone.’”,”‘.$user_address.’”)’;
if (!(mysql_query($sql))) {echo “New record created Error”;}

$sql_last_update = ‘UPDATE `Update` SET `Last_Update` = “‘.$last_update.’” WHERE `ID` = 1’; // Update New value of Last_Update in Update table
if (!(mysql_query($sql_last_update))){echo “
Update Last Update Error
“;}

$sql_status_update = ‘UPDATE `imaesdbusers` SET `user_status_register`= “1” WHERE `ID` = ‘.$last_update; // Update New value of Last_Update in Update table
if (!(mysql_query($sql_status_update))){echo “
Update Status Error
“;}

$query_mail_nf = mysql_query(‘SELECT * FROM `NF` WHERE `Code3`= “‘.$ID_country.’”‘);
$query_data = mysql_fetch_assoc($query_mail_nf);
$mail_nf = $query_data[Email];
$country_nf = $query_data[Country];
$fullname_nf = $query_data[Full_Name];

// Send E-mail to NF (call function from mail.php)
if ($mail_nf != “”){ sendmail($user_type[meta_value],$mail_nf,$country_nf,$fullname_nf,$user_gym_name,$user_gym_code,$user_birthdate,$user_address,$user_email,$user_phone,$user_first_name,$user_last_name); }
}
}
else if($user_type[meta_value] == “Guest”){
// Guest
$sql = ‘INSERT INTO `Guest`(`User_ID`, `N_Code3`, `Gym_Name`, `Gym_ID`, `Guest_Birthdate`, `Guest_Address`, `Guest_Email`, `Guest_Tel`, `Guest_Type`, `Guest_Fname`, `Guest_Lname`)
VALUES (“‘.$last_update.’”,”‘.$ID_country.’”,”‘.$user_gym_name.’”,”‘.$user_gym_code.’”,”‘.$user_birthdate.’”,”‘.$user_address.’”,”‘.$user_email.’”,”‘.$user_phone.’”,”‘.$user_type[meta_value].’”,”‘.$user_first_name.’”,”‘.$user_last_name.’”)’;
if (!(mysql_query($sql))) {echo “New record created Error”;}
$sql_last_update = ‘UPDATE `Update` SET `Last_Update` = “‘.$last_update.’” WHERE `ID` = 1’; // Update New value of Last_Update in Update table
if (!(mysql_query($sql_last_update))){echo “
Update Last Update Error
“;}

$sql_status_update = ‘UPDATE `imaesdbusers` SET `user_status_register`= “4” WHERE `ID` = ‘.$last_update; // Update New value of Last_Update in Update table
if (!(mysql_query($sql_status_update))){echo “
Update Status Error
“;}
/*
$query_mail_nf = mysql_query(‘SELECT * FROM `NF` WHERE `Code3`= “‘.$ID_country.’”‘);
$query_data = mysql_fetch_assoc($query_mail_nf);
$mail_nf = $query_data[Email];
$country_nf = $query_data[Country];
$fullname_nf = $query_data[Full_Name];

// Send E-mail to NF (call function from mail.php)
if ($mail_nf != “”){ sendmail($user_type[meta_value],$mail_nf,$country_nf,$fullname_nf,$user_gym_name,$user_gym_code,$user_birthdate,$user_address,$user_email,$user_phone,$user_first_name,$user_last_name); }
*/
}
else if($user_type[meta_value] !== “NF”){
$user_gender = $user_type[meta_value];
$sql = ‘INSERT INTO `Individual`(`User_ID`, `N_Code3`, `Gym_Name`, `Gym_ID`, `INV_Birthdate`, `INV_Address`, `INV_Email`, `INV_Tel`, `INV_Type`, `INV_Fname`, `INV_Lname`)
VALUES (“‘.$last_update.’”,”‘.$ID_country.’”,”‘.$user_gym_name.’”,”‘.$user_gym_code.’”,”‘.$user_birthdate.’”,”‘.$user_address.’”,”‘.$user_email.’”,”‘.$user_phone.’”,”‘.$user_gender.’”,”‘.$user_first_name.’”,”‘.$user_last_name.’”)’;
if (!(mysql_query($sql))) {echo “New record created Error”;}

$sql_last_update = ‘UPDATE `Update` SET `Last_Update` = “‘.$last_update.’” WHERE `ID` = 1’; // Update New value of Last_Update in Update table
if (!(mysql_query($sql_last_update))){echo “
Update Last Update Error
“;}

$sql_status_update = ‘UPDATE `imaesdbusers` SET `user_status_register`= “2” WHERE `ID` = ‘.$last_update; // Update status in user table
if (!(mysql_query($sql_status_update))){echo “
Update Status Error
“;}

$query_mail_nf = mysql_query(‘SELECT * FROM `NF` WHERE `Code3`= “‘.$ID_country.’”‘);
$query_data = mysql_fetch_assoc($query_mail_nf);
$mail_nf = $query_data[Email];
$country_nf = $query_data[Country];
$fullname_nf = $query_data[Full_Name];

// Send E-mail to NF (call function from mail.php)
if ($mail_nf != “”){ sendmail($user_type[meta_value],$mail_nf,$country_nf,$fullname_nf,$user_gym_name,$user_gym_code,$user_birthdate,$user_address,$user_email,$user_phone,$user_first_name,$user_last_name); }
}
else if($user_type[meta_value] == “NF”){
$sql_status_update = ‘UPDATE `imaesdbusers` SET `user_status_register`= “3” WHERE `ID` = ‘.$last_update; // Update New value of Last_Update in Update table
if (!(mysql_query($sql_status_update))){echo “
Update Status Error
“;}

$sql_last_update = ‘UPDATE `Update` SET `Last_Update` = “‘.$last_update.’” WHERE `ID` = 1’; // Update New value of Last_Update in Update table
if (!(mysql_query($sql_last_update))){echo “
Update Last Update Error
“;}

$fullname = $user_gym_name.” “.$user_last_name;
$fulladdress = $user_address.” “.$user_city.” “.$name_country.” “.$user_zip;

$name_country = strtoupper($name_country);

$sql = “INSERT INTO `NF`( `UserID`, `Code3`, `Country`, `Full_Name`, `Code_NF`, `Establish`, `Address`, `Tel`, `Email`) VALUES (‘$last_update’,’$ID_country’,’$name_country’,’$fullname’,”,’$user_birthdate’,’$fulladdress’,’$user_phone’,’$user_email’)”;
if (!(mysql_query($sql))) {echo “New record created Error”;}
}
}
}
}
[/insert_php]
[/private]