Advertisement
Guest User

Untitled

a guest
Oct 21st, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 5.42 KB | None | 0 0
  1. function saveContact($db_conn){
  2. $field_data = array();
  3. $qry_ct = "insert into contact set ct_type= ?";
  4. $field_data[] = $_SESSION['ct_type'];
  5. if (isset($_SESSION['ct_first_name'])){
  6. $qry_ct .= ", ct_first_name= ?";
  7. $field_data[] = $_SESSION['ct_first_name'];
  8. }
  9. if (isset($_SESSION['ct_last_name'])){
  10. $qry_ct .= ", ct_last_name= ?";
  11. $field_data[] = $_SESSION['ct_last_name'];
  12. }
  13. if (isset($_SESSION['ct_disp_name'])){
  14. $qry_ct .= ", ct_disp_name= ?";
  15. $field_data[] = $_SESSION['ct_disp_name'];
  16. }
  17. $qry_ct .= ", ct_deleted= ?";
  18. $field_data[] = "N";
  19. $stmt = $db_conn->prepare($qry_ct);
  20. if (!$stmt){
  21. echo "<p>Error in contact prepare: ".$dbc->errorCode()."</p>\n<p>Message ".implode($dbc->errorInfo())."</p>\n";
  22. exit(1);
  23. }
  24. $status = $stmt->execute($field_data);
  25. if (!$status){
  26. echo "<p>Error in contact execute: ".$stmt->errorCode()."</p>\n<p>Message ".implode($stmt->errorInfo())."</p>\n";
  27. exit(1);
  28. }
  29. $id = $db_conn->lastInsertId();
  30. unset($field_data);
  31.  
  32. $field_data = array();
  33. if (isset($_SESSION['ad_type'])){
  34. $qry_ad = "insert into contact_address set ad_ct_id= ?, ad_type= ?";
  35. $field_data[] = $id;
  36. $field_data[] = $_SESSION['ad_type'];
  37. if (isset($_SESSION['ad_line_1'])){
  38. $qry_ad .= ", ad_line_1= ?";
  39. $field_data[] = $_SESSION['ad_line_1'];
  40. }
  41. if (isset($_SESSION['ad_line_2'])){
  42. $qry_ad .= ", ad_line_2= ?";
  43. $field_data[] = $_SESSION['ad_line_2'];
  44. }
  45. if (isset($_SESSION['ad_line_3'])){
  46. $qry_ad .= ", ad_line_3= ?";
  47. $field_data[] = $_SESSION['ad_line_3'];
  48. }
  49. if (isset($_SESSION['ad_city'])){
  50. $qry_ad .= ", ad_city= ?";
  51. $field_data[] = $_SESSION['ad_city'];
  52. }
  53. if (isset($_SESSION['ad_province'])){
  54. $qry_ad .= ", ad_province= ?";
  55. $field_data[] = $_SESSION['ad_province'];
  56. }
  57. if (isset($_SESSION['ad_post_code'])){
  58. $qry_ad .= ", ad_post_code= ?";
  59. $field_data[] = $_SESSION['ad_post_code'];
  60. }
  61. if (isset($_SESSION['ad_contry'])){
  62. $qry_ad .= ", ad_country= ?";
  63. $field_data[] = $_SESSION['ad_country'];
  64. }
  65. $qry_ad .= ", ad_active= ?;";
  66. $field_data[] = "y";
  67. $stmt = $db_conn->prepare($qry_ad);
  68. if (!$stmt){
  69. echo "<p>Error in address prepare: ".$dbc->errorCode()."</p>\n<p>Message ".implode($dbc->errorInfo())."</p>\n";
  70. exit(1);
  71. }
  72. $status = $stmt->execute($field_data);
  73. if (!$status){
  74. echo "<p>Error in address execute ".$stmt->errorCode()."</p>\n<p>Message ".implode($stmt->errorInfo())."</p>\n";
  75. exit(1);
  76. }
  77. }
  78. unset($field_data);
  79.  
  80. $field_data = array();
  81. if (isset($_SESSION['ph_type'])){
  82. $qry_ph = "insert into contact_phone set ph_ct_id= ?, ph_type = ?";
  83. $field_data[] = $id;
  84. $field_data[] = $_SESSION['ph_type'];
  85. if (isset($_SESSION['ph_number'])){
  86. $qry_ph .= ", ph_number= ?";
  87. $field_data[] = $_SESSION['ph_number'];
  88. }
  89. $qry_ph .= ", ph_active= ?;";
  90. $field_data[] = "Y";
  91. $stmt = $db_conn->prepare($qry_ph);
  92. if (!$stmt){
  93. echo "<p>Error in phones prepare: ".$dbc->errorCode()."</p>\n<p>Message ".implode($dbc->errorInfo())."</p>\n";
  94. exit(1);
  95. }
  96. $status = $stmt->execute($field_data);
  97. if (!$status){
  98. echo "<p>Error in phone execute ".$stmt->errorCode()."</p>\n<p>Message ".implode($stmt->errorInfo())."</p>\n";
  99. exit(1);
  100. }
  101. }
  102. unset($field_data);
  103.  
  104. $field_data = array();
  105. if (isset($_SESSION['em_type'])){
  106. $qry_em = "insert into contact_email set em_ct_id= ?, em_type = ?";
  107. $field_data[] = $id;
  108. $field_data[] = $_SESSION['em_type'];
  109. if (isset($_SESSION['em_email'])){
  110. $qry_em .= ", em_email= ?";
  111. $field_data[] = $_SESSION['em_email'];
  112. }
  113. $qry_em .= ", em_active= ?;";
  114. $field_data[] = "Y";
  115. $stmt = $db_conn->prepare($qry_em);
  116. if (!$stmt){
  117. echo "<p>Error in email prepare: ".$dbc->errorCode()."</p>\n<p>Message ".implode($dbc->errorInfo())."</p>\n";
  118. exit(1);
  119. }
  120. $status = $stmt->execute($field_data);
  121. if (!$status){
  122. echo "<p>Error in email execute ".$stmt->errorCode()."</p>\n<p>Message ".implode($stmt->errorInfo())."</p>\n";
  123. exit(1);
  124. }
  125. }
  126. unset($field_data);
  127.  
  128. $field_data = array();
  129. if (isset($_SESSION['we_type'])){
  130. $qry_we = "insert into contact_web set we_ct_id= ?, we_type = ?";
  131. $field_data[] = $id;
  132. $field_data[] = $_SESSION['we_type'];
  133. if (isset($_SESSION['we_url'])){
  134. $qry_we .= ", we_url= ?";
  135. $field_data[] = $_SESSION['we_url'];
  136. }
  137. $qry_we .= ", we_active= ?";
  138. $field_data[] = "Y";
  139. $stmt = $db_conn->prepare($qry_we);
  140. if (!$stmt){
  141. echo "<p>Error in URL prepare: ".$dbc->errorCode()."</p>\n<p>Message ".implode($dbc->errorInfo())."</p>\n";
  142. exit(1);
  143. }
  144. $status = $stmt->execute($field_data);
  145. if (!$status){
  146. echo "<p>Error in URL execute ".$stmt->errorCode()."</p>\n<p>Message ".implode($stmt->errorInfo())."</p>\n";
  147. exit(1);
  148. }
  149. }
  150. unset($field_data);
  151.  
  152. $field_data = array();
  153. if (isset($_SESSION['no_note'])){
  154. $qry_no = "insert into contact_note set no_ct_id= ?";
  155. $field_data [] = $id;
  156. $qry_no .= ", no_type= ?";
  157. $field_data[] = "";
  158. $qry_no .= ", no_note= ?";
  159. $field_data[] = $_SESSION['no_note'];
  160. $stmt = $db_conn->prepare($qry_no);
  161. if (!$stmt){
  162. echo "<p>Error in note prepare: ".$dbc->errorCode()."</p>\n<p>Message ".implode($dbc->errorInfo())."</p>\n";
  163. exit(1);
  164. }
  165. $status = $stmt->execute($field_data);
  166. if (!$status){
  167. echo "<p>Error in note execute ".$stmt->errorCode()."</p>\n<p>Message ".implode($stmt->errorInfo())."</p>\n";
  168. exit(1);
  169. }
  170. }
  171. unset($field_data);
  172. }
  173. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement