Advertisement
Guest User

Untitled

a guest
Feb 21st, 2013
148
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.85 KB | None | 0 0
  1. // file template_MyForm.php
  2. <?php
  3. /*
  4. Template Name: MyForm
  5. */
  6. ?>
  7.  
  8. <?php get_header(); ?>
  9.  
  10.  
  11. <div class="itm_contenidor">   
  12. <form id="itm_form" >
  13. Nombre: <input type="text" name="itm_name" placeholder="Nombre" >
  14. Email: <input type="text" name="itm_email" placeholder="Tu email" >
  15. <input type="submit" value="Enviar">
  16. <input type="hidden" name="itm_oculto" value="0">
  17.  
  18. </form>
  19. </div>
  20. <div id="destino"></div>
  21.  
  22. <?php get_footer(); ?>
  23.  
  24. <?php
  25.  
  26. /*
  27. Plugin Name: ITM SIMPLE PAYPAL
  28. Plugin URI: http://aprendesap.com
  29. Description: A simple plugin that calls paypal
  30. Author: Ignasi Tort
  31. Author URI: http://aprendesap.com
  32. Version: 1.0
  33. License: GNU
  34. */
  35.  
  36.  
  37.     function itm_scripts_load_cdn()  
  38.     {  
  39.         // Deregister the included library  
  40.         wp_deregister_script( 'jquery' );  // Comment this line if you not use Google's CDN
  41.          
  42.         // Register the library again from Google's CDN  // Comment this line if you not use Google's CDN
  43.         wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', array(), null, false );  
  44.          
  45.         // Register the script like this for a plugin:      
  46.         wp_register_script( 'itm_simple_paypal', plugins_url( '/itm_simple_paypal.js', __FILE__ ), array( 'jquery' ) );
  47.      
  48.         // For either a plugin or a theme, you can then enqueue the script:
  49.         wp_enqueue_script( 'itm_simple_paypal');  
  50.     }
  51.     add_action( 'wp_enqueue_scripts', 'itm_scripts_load_cdn' );  
  52.  
  53.  
  54.  
  55.     function itm_simple_paypal_styles()  
  56.     {  
  57.         // Register the style like this for a plugin:  
  58.         wp_register_style( 'itm-paypal-style', plugins_url( '/itm_simple_paypal.css', __FILE__ ), array(), '20130131', 'all' );  
  59.      
  60.         // For either a plugin or a theme, you can then enqueue the style:  
  61.         wp_enqueue_style( 'itm-paypal-style' );  
  62.     }  
  63.     add_action( 'wp_enqueue_scripts', 'itm_simple_paypal_styles' );  
  64.  
  65.  
  66.  
  67. ?>
  68.  
  69.  
  70. // file itm_simple_paypal.js
  71. jQuery(document).ready(function(){
  72.    jQuery("#itm_form").submit(function(evento){
  73.      evento.preventDefault();
  74.      var form = jQuery(this);
  75.      jQuery.post("itm_simple_paypal_process.php",jQuery(form).serialize(), function(data){
  76.        
  77.     // jQuery ('#destino').html(data);  // fills the div with data
  78.     alert(data); // data appears on alert window
  79.             });
  80.        });
  81.        
  82.     // other events below  
  83.      
  84. })    
  85.  
  86.  
  87. // file itm_simple_paypal.process.php
  88.  
  89. <?php
  90.  
  91.  include '../../../wp-load.php';
  92. if( isset ($_POST['itm_email'])){
  93.     if ( isset($_POST['itm_email'] ) && is_email($_POST['itm_email']) ) {
  94.         $name = $_POST["itm_name"];
  95.         $email = $_POST["itm_email"];
  96.         echo '
  97.         <h3>Formulario correcto</h3>
  98.         <p>Gracias </p>
  99.         '+$name+' '+$email+' ';
  100.     }
  101.    
  102. } else {
  103. echo '
  104.         <h3>Formulario erróneo</h3>
  105.         <p>Corrige los errores</p>
  106.         '+$name+' '+$email+' ';
  107.  
  108.  
  109. }
  110.  
  111.  
  112. ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement