Advertisement
Guest User

Untitled

a guest
Jan 17th, 2017
132
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 6.45 KB | None | 0 0
  1. <form class="RegForm" method="post" action="" >
  2. <br>
  3. <h2 style ="">Registration Form </h2>
  4. <div class ="col-md-3" style="clear:both;">
  5. <label style="font-size:12px;"> First Name:</label>
  6. <input type="text" id="RF_FName" name="RF_FName" />
  7. </div>
  8. <div class ="col-md-3">
  9. <label style="font-size:12px;">Middle Name:</label>
  10. <input type="text" id="RF_MName" name="RF_MName" />
  11. </div>
  12. <div class ="col-md-3">
  13. <label style="font-size:12px;">Last Name:</label>
  14. <input type="text" id="RF_LName" name="RF_LName" />
  15. </div>
  16. <br><br>
  17. <div class ="col-md-3" style="clear:both;">
  18. <label style="font-size:12px;"> Password:</label>
  19. <input type="Password" id="RF_Pass" name="RF_Pass" />
  20.  
  21. </div>
  22. <div class ="col-md-3">
  23. <label style="font-size:12px;">Confirm Password:</label>
  24. <input type="Password" id="RF_CPass" name="RF_CPass" />
  25. </div>
  26.  
  27. <br><br>
  28. <div class ="col-md-3" style="clear:both;">
  29. <label style="font-size:12px;">Email ID:</label>
  30. <input type="text" id="RF_Email" name="RF_Email" />
  31. </div>
  32. <div class ="col-md-3">
  33. <label style="font-size:12px;">Contact No:</label>
  34. <input type="text" id="RF_Contact" name="RF_Contact" />
  35. </div>
  36. <br><br>
  37. <div class ="col-md-3" style="clear:both;">
  38. <label style="font-size:12px;">Address 1:</label>
  39. <input type="text" id="RF_Address1" name="RF_Address1" />
  40. </div>
  41. <div class ="col-md-3" >
  42. <label style="font-size:12px;">Address 2:</label>
  43. <input type="text" id="RF_Address2" name="RF_Address2" />
  44. </div>
  45. <div class ="col-md-3">
  46. <label style="font-size:12px;">Address 3:</label>
  47. <input type="text" id="RF_Address3" name="RF_Address3" />
  48. </div>
  49.  
  50. <br><br>
  51.  
  52. <div class ="col-md-3" style="clear:both;">
  53. <label style="font-size:12px;">Pin Code:</label>
  54. <input type="text" id="RF_Pin" name="RF_Pin" />
  55. </div>
  56. <div class ="col-md-3" >
  57. <label style="font-size:12px;">City:</label><br>
  58. <input type="text" id="RF_City" name="RF_City" />
  59. </div>
  60. <div class ="col-md-3">
  61. <label style="font-size:12px;">State:</label><br>
  62. <input type="text" id="RF_State" name="RF_State" />
  63. </div>
  64. <br><br>
  65. <div class ="col-md-3"style="clear:both;" ></div>
  66.  
  67. <br> <br>
  68. <div class ="col-md-3" style="clear:both;" >
  69. <input id="RegisterUser" type="submit" Value="Register" name="submit" />
  70. </div>
  71.  
  72. </form>
  73.  
  74. jQuery(document).ready(function($){
  75.  
  76. var RegisterUser = document.getElementById('RegisterUser');
  77.  
  78. var ajaxFunctionformprocess = function(fromdata, action){
  79. $.ajax({
  80. type:'post',
  81. url: Registerform.url,
  82. data:{
  83. action:action,
  84. data:fromdata,
  85. security:Registerform.security,
  86.  
  87. },
  88. success:function(reponse){
  89. $('div.msg').html(reponse);
  90. },
  91. error:function(response){
  92. alert(response);
  93. }
  94.  
  95. });
  96. }
  97.  
  98. RegisterUser.addEventListener('click', function(event){
  99. event.preventDefault();
  100. var fromdata = {
  101. 'Reg_FName':document.getElementById('Reg_FName').value,
  102. 'Reg_MName':document.getElementById('Reg_MName').value,
  103. 'Reg_LName':document.getElementById('Reg_LName').value,
  104. 'Reg_Password':document.getElementById('Reg_Password').value,
  105. 'Reg_CPassword':document.getElementById('Reg_CPassword').value,
  106. 'Reg_Email':document.getElementById('Reg_Email').value,
  107. 'Reg_Contact':document.getElementById('Reg_Contact').value,
  108. 'Reg_Address1':document.getElementById('Reg_Address1').value,
  109. 'Reg_Address2':document.getElementById('Reg_Address2').value,
  110. 'Reg_Address3':document.getElementById('Reg_Address3').value,
  111. 'Reg_Pin':document.getElementById('Reg_Pin').value,
  112. 'Reg_City':document.getElementById('Reg_City').value,
  113. 'Reg_State':document.getElementById('Reg_State').value,
  114. 'Reg_Country':document.getElementById('Reg_Country').value,
  115. };
  116. ajaxFunctionformprocess(fromdata, 'form_Register_function');
  117.  
  118. });
  119.  
  120. });
  121.  
  122. function RegisterForm_style_andscripts(){
  123. //wp_enqueue_style('parent-style', get_template_directory_uri() . '/style.css' );
  124. wp_enqueue_script('ajax-function', get_stylesheet_directory_uri() . '/js/RegisterUser.js', array('jquery'), '1.0', true );
  125. wp_localize_script( 'ajax-function', 'Registerform', array(
  126. 'url'=> admin_url('admin-ajax.php'),
  127. 'security'=> wp_create_nonce('our-nonce')
  128. ) );
  129. }
  130.  
  131. add_action('wp_enqueue_scripts','RegisterForm_style_andscripts');
  132.  
  133.  
  134. function form_Register_function(){
  135.  
  136. require_once(dirname( __FILE__ ).'/../../../wp-load.php');
  137. $data = $_POST['data'];
  138. global $wpdb;
  139.  
  140. if( !check_ajax_referer('our-nonce', 'security' ) ){
  141.  
  142. wp_send_json_error('security failed');
  143.  
  144. return;
  145.  
  146. }
  147. //var_dump($data);
  148. $Reg_FName=$data['Reg_FName'];
  149. $Reg_MName=$data['Reg_MName'];
  150. $Reg_LName=$data['Reg_LName'];
  151. $Reg_Password=$data['Reg_Password'];
  152. $Reg_CPassword=$data['Reg_CPassword'];
  153. $Reg_Email=$data['Reg_Email'];
  154. $Reg_Contact=$data['Reg_Contact'];
  155. $Reg_Address1=$data['Reg_Address1'];
  156. $Reg_Address2=$data['Reg_Address2'];
  157. $Reg_Address3=$data['Reg_Address3'];
  158. $Reg_Pin=$data['Reg_Pin'];
  159. $Reg_City=$data['Reg_City'];
  160. $Reg_State=$data['Reg_State'];
  161. $Reg_Country=$data['Reg_Country'];
  162.  
  163.  
  164. $table_name = "Pooja_Registration";
  165. $wpdb->insert($table_name, array ('Reg_FName' => $Reg_FName, 'Reg_MName' => $Reg_MName,'Reg_LName' => $Reg_LName,'Reg_Password' => $Reg_Password,'Reg_CPassword' => $Reg_CPassword,'Reg_Email' => $Reg_Email,'Reg_Contact' => $Reg_Contact,'Reg_Address1' => $Reg_Address1,'Reg_Address2' => $Reg_Address2,'Reg_Address3' => $Reg_Address3,'Reg_Pin' => $Reg_Pin,'Reg_City' => $Reg_City,'Reg_State' => $Reg_State,'Reg_Country' => $Reg_Country) );
  166.  
  167. $wpdb->show_errors();
  168. $wpdb->print_error();
  169. echo 'From Submitted Successfully';
  170.  
  171. die();
  172. }
  173.  
  174.  
  175. add_action('wp_ajax_nopriv_form_Register_function','form_Register_function');
  176. add_action('wp_ajax_form_Register_function','form_Register_function');
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement