Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // file template_MyForm.php
- <?php
- /*
- Template Name: MyForm
- */
- ?>
- <?php get_header(); ?>
- <div class="itm_contenidor">
- <form id="itm_form" >
- Nombre: <input type="text" name="itm_name" placeholder="Nombre" >
- Email: <input type="text" name="itm_email" placeholder="Tu email" >
- <input type="submit" value="Enviar">
- <input type="hidden" name="itm_oculto" value="0">
- </form>
- </div>
- <div id="destino"></div>
- <?php get_footer(); ?>
- <?php
- /*
- Plugin Name: ITM SIMPLE PAYPAL
- Plugin URI: http://aprendesap.com
- Description: A simple plugin that calls paypal
- Author: Ignasi Tort
- Author URI: http://aprendesap.com
- Version: 1.0
- License: GNU
- */
- function itm_scripts_load_cdn()
- {
- // Deregister the included library
- wp_deregister_script( 'jquery' ); // Comment this line if you not use Google's CDN
- // Register the library again from Google's CDN // Comment this line if you not use Google's CDN
- wp_register_script( 'jquery', 'http://ajax.googleapis.com/ajax/libs/jquery/1.8.3/jquery.min.js', array(), null, false );
- // Register the script like this for a plugin:
- wp_register_script( 'itm_simple_paypal', plugins_url( '/itm_simple_paypal.js', __FILE__ ), array( 'jquery' ) );
- // For either a plugin or a theme, you can then enqueue the script:
- wp_enqueue_script( 'itm_simple_paypal');
- }
- add_action( 'wp_enqueue_scripts', 'itm_scripts_load_cdn' );
- function itm_simple_paypal_styles()
- {
- // Register the style like this for a plugin:
- wp_register_style( 'itm-paypal-style', plugins_url( '/itm_simple_paypal.css', __FILE__ ), array(), '20130131', 'all' );
- // For either a plugin or a theme, you can then enqueue the style:
- wp_enqueue_style( 'itm-paypal-style' );
- }
- add_action( 'wp_enqueue_scripts', 'itm_simple_paypal_styles' );
- ?>
- // file itm_simple_paypal.js
- jQuery(document).ready(function(){
- jQuery("#itm_form").submit(function(evento){
- evento.preventDefault();
- var form = jQuery(this);
- jQuery.post("itm_simple_paypal_process.php",jQuery(form).serialize(), function(data){
- // jQuery ('#destino').html(data); // fills the div with data
- alert(data); // data appears on alert window
- });
- });
- // other events below
- })
- // file itm_simple_paypal.process.php
- <?php
- include '../../../wp-load.php';
- if( isset ($_POST['itm_email'])){
- if ( isset($_POST['itm_email'] ) && is_email($_POST['itm_email']) ) {
- $name = $_POST["itm_name"];
- $email = $_POST["itm_email"];
- echo '
- <h3>Formulario correcto</h3>
- <p>Gracias </p>
- '+$name+' '+$email+' ';
- }
- } else {
- echo '
- <h3>Formulario erróneo</h3>
- <p>Corrige los errores</p>
- '+$name+' '+$email+' ';
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement