HEX
Server: Apache
System: Linux wyse1.wyseservers.com 4.18.0-553.124.4.el8_10.x86_64 #1 SMP Fri May 15 04:14:14 EDT 2026 x86_64
User: kochikidswysewor (1061)
PHP: 8.3.33
Disabled: NONE
Upload Files
File: /home/kochikidswysewor/www/wp-content/themes/children-charity-child/page-sponsor-new-page.php
<?php session_start();
/**
 * Template Name: Sponsor
 */


get_header();

list($cmsmasters_layout) = children_charity_theme_page_layout_scheme();
  $child_id = $_POST['child_id'];
  $image = get_the_post_thumbnail($child_id,'child_image_cr');
  $categories = get_the_terms( $child_id, 'children_categories' );
  $cat_name = $categories[0]->name;
  $amount_utilisation = get_field('amount_utilisation',$child_id);?>
<section class="our-sponser">
  <div class="container">
    <div class="sponsor_donate_wrap">
      <h2>Donate</h2>
      <div class="row">
        <div class="col-lg-7 col-md-7 col-sm-6">
          <table>
            <tbody>
              <tr>
                <td class="hd">Name :</td>
                <td class="des"><?php echo get_the_title($child_id);?></td>
              </tr>
              <tr>
                <td class="hd">Age :</td>
                <td class="des"><?php echo get_field('age',$child_id);?> years</td>
              </tr>
              <tr>
                <td class="hd">Birthday :</td>
                <td class="des"><?php echo get_field('birthday',$child_id); ?></td>
              </tr>
              <tr>
                <td class="hd">Gender :</td>
                <td class="des"><?php echo $cat_name; ?></td>
              </tr>
            </tbody>
          </table>
          <?php echo $amount_utilisation; ?>
        </div>
        <div class="col-lg-5 col-md-5 col-sm-6">
           <?php if($image){?>
                    <figure class="kidImg"><?php echo $image; ?></figure>
               <?php }else{?>
                    <figure class="kidImg"><img src="<?php bloginfo('wpurl')?>/wp-content/uploads/2015/01/01.jpg"></figure>
               <?php } ?>
        </div> 
         <form action="https://www.sandbox.paypal.com/cgi-bin/webscr" method="post" target="_top"  name="donation">
          <input type="hidden" name="amount" id="amount_pass" value="">
          <input type="hidden" name="cmd" value="_donations"/>
          <input type="hidden" name="business" value="sb-sgpao841819@business.example.com" />
          <input type="hidden" name="notify_url" value="https://techwyse.com/wp-content/themes/techwyse/sponsor-response.php"/>
          <input type="hidden" name="currency_code" value="CAD" />
            <div class="col-sm-12">
              <div style="display:flex;">
                <div class="dnt_amt">
                  <div class="input-holder">
                    <input type="text" name="sponsor_amount" id="sponsor_amount" class="required form-control" placeholder="Amount">
                  </div>
                </div>
                <div style="margin-left:auto;">
                  <input type="submit" id="donate_button" class="donate_button btn dnt_more" src="https://www.paypalobjects.com/en_US/i/btn/btn_donateCC_LG.gif" border="0" name="Donate" alt="Donate" />
                </div>
              </div>
              <b>To view all the Child sponsored by the user <a href="<?php bloginfo('wpurl');?>/sponsor-dashboard/">Click here</a></b>
            </div>
      </div>  
    </div>
  </div>
</section>
<script>
  jQuery('.donate_button').click(function(){ 
  var sponsor_amount = jQuery("#sponsor_amount").val(); console.log(sponsor_amount);
  jQuery("#amount_pass").val(sponsor_amount); console.log(jQuery("#amount_pass").val());
     });
 
    // Validation
     jQuery(document).ready(function() {      
        jQuery('#donate_button').click(function(e){
          var amount = jQuery("#sponsor_amount").val(); alert(amount);
          document.cookie="amount="+amount+"";
          var $formId = jQuery(this).parents('form');
          var formAction = $formId.attr('action');
          var emailReg = /^([\w-\.]+@([\w-]+\.)+[\w-]{2,4})?$/;
          var phoneReg = /^\(?(\d{3})\)?[- ]?(\d{3})[- ]?(\d{4})$/;
          var $error = jQuery('<span class="error"></span>');
      
          // Prepare the form for validation - remove previous errors
          jQuery('span.error').remove();
          jQuery('.input-holder').removeClass('error');
          
          // Validate all inputs with the class "required"
          jQuery('.required',$formId).each(function(){
            var inputVal = jQuery.trim(jQuery(this).val());
            var fieldtitle = jQuery(this).attr("title");
            var fieldname=jQuery(this).attr("name");
            var $parentTag = jQuery(this).parent(); //alert($parentTag);
            if(inputVal == '' || inputVal=='-1')
            {  
              $parentTag.addClass('error').append($error.clone().text('Please enter the amount to donate')); 
              jQuery(this).focus();
              jQuery('#donate_button').show(); 
              return false;
            }

          });   
          // All validation complete - Check if any errors exist
          // If has errors
          if (jQuery('span.error').length > 0) {
            
            jQuery('span.error').each(function(){
              
              // Set the distance for the error animation
              var distance = 5;
              
              // Get the error dimensions
              var width = jQuery(this).outerWidth();
              
              // Calculate starting position
              var start = width + distance;
              
              // Set the initial CSS
              jQuery(this).show().css({
                display: 'block',
                opacity: 1
              })
              // Animate the error message
              .animate({
                opacity: 1
              }, 'slow');
              
            });
            
             e.preventDefault();
      
          }else{
            <?php 
          $post_id = $child_id;
          $sponser_array = array(); 
            if( have_rows('sponsor_user_details',$post_id) ):
            while( have_rows('sponsor_user_details',$post_id) ): the_row(); 
              $sponser_array[] = get_sub_field('sponsors_',$post_id); 
            endwhile; endif;
          $user = wp_get_current_user(); 
          $user_id = $user->ID;
          $sponsored_amount = $_COOKIE['amount'];
          if (!in_array($user_id, $sponser_array)){ echo "jdhfjhsdj";
            if ( ! add_post_meta( $post_id, 'sponsors_', $user_id, true ) ) { 
            update_post_meta ( $post_id, 'sponsors_', $user_id );
            $row = array(
            'sponsors_' => $user_id,
            'sponser_amount'   => $sponsored_amount,
            );

            add_row('sponsor_user_details', $row , $post_id);
            update_row('sponsor_user_details', $row , $post_id);
            update_row('sponsor_user_details', 2 ,$row, $post_id);
            }
          }
          ?>
            document.donation.submit();
          }
          // Prevent form submission
            e.preventDefault();
        });
        // Fade out error message when input field gains focus
        jQuery('.required').keypress(function(){
          var $parent = jQuery(this).parent();
          $parent.removeClass('error');
          jQuery('span.error',$parent).fadeOut();
        });
      });
</script>
<?php get_footer();