Jump to content

Recommended Posts

hi there, I have some PHP calcs from my old website that I'd like to incorporate into my new WordPress site. I've pasted the code where I think it need to go but no success. Could someone please help?

 

Here is my php:

<?php
			if (($_REQUEST['form_complete'])) {
				$fgross_pay          = $_REQUEST['gross_pay'];
				$fsgross_pay         = $_REQUEST['sgross_pay'];
				$fo_pay              = $_REQUEST['o_pay'];
				$form_complete      = $_REQUEST['form_complete'];			

				$gross_pay = preg_replace('/\D/', '', $fgross_pay);
				$sgross_pay = preg_replace('/\D/', '', $fsgross_pay);
				$o_pay = preg_replace('/\D/', '', $fo_pay);

				if ($gross_pay) {
					$ttl_pay = $gross_pay+$sgross_pay+$o_pay;
				}
				if ($ttl_pay) {
					$GDS = 0.32*$ttl_pay;
				}					
			}				
		?>
		<form name="GDS-info" class="formular" method="post">
			<input type="hidden" name="form_complete" value="1">
			<table cellpadding="2" cellspacing="0" border="0" width="100%" align="center">
				<tr valign="top" bgcolor="#cccccc">
					<td align="center" colspan="2"><b>GDS Calculator</b></td>
				</tr>
				<tr valign="top" bgcolor="#eeeeee"><td colspan="2"> </td></tr>
				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">Gross monthly salary (before deductions)</td>
					<td><input type="text" size="10" name="gross_pay" value="<?php if($gross_pay){ echo $gross_pay; } else {echo " ";} ?>"></td>
				</tr>
				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">Your spouse's gross monthly salary (before deductions)</td>
					<td><input type="text" size="10" name="sgross_pay" value="<?php if($sgross_pay){ echo $sgross_pay; } else {echo " ";} ?>"></td>
				</tr>
				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">Other monthly income</td>
					<td><input type="text" size="10" name="o_pay" value="<?php if($o_pay){ echo $o_pay; } else {echo " ";} ?>"></td>
				</tr>

				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">(A) Total monthly income</td>
					<td><input type="text" size="10" value="<?php if($ttl_pay){ echo $ttl_pay; } else {echo " ";} ?>"></td>
				</tr>
				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">(B) Multiply (A) X 0.32 = GDS</td>
					<td><input type="text" size="10" value="<?php if($GDS){ echo round($GDS, 2); } else {echo " ";} ?>"></td>
				</tr>
				<tr><td><input type="submit" value="Calculate GDS"></td></tr>
			</table>
		</form>
	<?php
	if (($_REQUEST['form_complete2'])) {
						$fpay          = $_REQUEST['pay'];
						$fcar          = $_REQUEST['car'];
						$floan         = $_REQUEST['loan'];
						$fcredit       = $_REQUEST['credit'];
						$fodebt        = $_REQUEST['odebt'];

						$form_complete  = $_REQUEST['form_complete'];

						$pay = preg_replace('/\D/', '', $fpay);
						$car = preg_replace('/\D/', '', $fcar);
						$loan = preg_replace('/\D/', '', $floan);
						$credit = preg_replace('/\D/', '', $fcredit);
						$odebt = preg_replace('/\D/', '', $fodebt);


						$ttl_pay2 = $ttl_pay;	
						$ttl_debt = $car+$loan+$credit+$odebt;

						if ($ttl_debt) {
							if ($pay) {
								$TDS = $ttl_debt/$pay;
							}
							else {$pay = $_REQUEST['pay'];}
						}							
					}
	?>
	<form method="GET" name="TDS-info" action="http://www.realestatebram.com/WP/?page_id=118">
					<input type="hidden" name="form_complete2" value="1">
					<table cellpadding="2" cellspacing="0" border="0" width="100%" align="center">
						<tr valign="top" bgcolor="#cccccc">
							<td align="center" colspan="2"><b>TDS Calculator</b></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee"><td colspan="2"> </td></tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Total Monthly Income, (A) from GDS Calculator</td>
							<td><input type="text" size="10" name="pay" value="<?php if($ttl_pay){ echo $ttl_pay; } elseif ($pay){ echo $pay; } else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Monthly car loan or lease payment</td>
							<td><input type="text" size="10" name="car" value="<?php if($car){echo $car;} else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Monthly loan or line of credit payment</td>
							<td><input type="text" size="10" name="loan" value="<?php if($loan){echo $loan;} else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Monthly credit card payment</td>
							<td><input type="text" size="10" name="credit" value="<?php if($credit){echo $credit;} else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Other monthly payment(s)</td>
							<td><input type="text" size="10" name="odebt" value="<?php if($odebt){echo $odebt;} else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Your total monthly debt payments amount to</td>
							<td><input type="text" size="10" name="ttl_debt" value="<?php if($ttl_debt){ echo $ttl_debt; } else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Your TDS is</td>
							<td><input type="text" size="10" name="TDS" value="<?php if($TDS){ echo round($TDS, 2); } else {echo " ";} ?>"></td>
						</tr>							
						<tr><td><input type="submit" value="Calculate TDS"></td></tr>
					</table>
				</form>                
            </div>

 

here is the WP page I'd like the calculators to appear on and my attempt to add the calcs

<?php
/*
Template Name: Afford
*/
?>

<?php get_header(); ?>

    <article id="leftcol" class="left">

	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        	
            <?php ct_first_image_blog(); ?>
            
            <div id="article">
            
			<?php the_content(); ?>
                
                <?php //ADD YOUR CODE HERE ?>

		<?php
			if (($_REQUEST['form_complete'])) {
				$fgross_pay          = $_REQUEST['gross_pay'];
				$fsgross_pay         = $_REQUEST['sgross_pay'];
				$fo_pay              = $_REQUEST['o_pay'];
				$form_complete      = $_REQUEST['form_complete'];			

				$gross_pay = preg_replace('/\D/', '', $fgross_pay);
				$sgross_pay = preg_replace('/\D/', '', $fsgross_pay);
				$o_pay = preg_replace('/\D/', '', $fo_pay);

				if ($gross_pay) {
					$ttl_pay = $gross_pay+$sgross_pay+$o_pay;
				}
				if ($ttl_pay) {
					$GDS = 0.32*$ttl_pay;
				}					
			}				
		?>
		<form name="GDS-info" class="formular" method="post">
			<input type="hidden" name="form_complete" value="1">
			<table cellpadding="2" cellspacing="0" border="0" width="100%" align="center">
				<tr valign="top" bgcolor="#cccccc">
					<td align="center" colspan="2"><b>GDS Calculator</b></td>
				</tr>
				<tr valign="top" bgcolor="#eeeeee"><td colspan="2"> </td></tr>
				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">Gross monthly salary (before deductions)</td>
					<td><input type="text" size="10" name="gross_pay" value="<?php if($gross_pay){ echo $gross_pay; } else {echo " ";} ?>"></td>
				</tr>
				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">Your spouse's gross monthly salary (before deductions)</td>
					<td><input type="text" size="10" name="sgross_pay" value="<?php if($sgross_pay){ echo $sgross_pay; } else {echo " ";} ?>"></td>
				</tr>
				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">Other monthly income</td>
					<td><input type="text" size="10" name="o_pay" value="<?php if($o_pay){ echo $o_pay; } else {echo " ";} ?>"></td>
				</tr>

				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">(A) Total monthly income</td>
					<td><input type="text" size="10" value="<?php if($ttl_pay){ echo $ttl_pay; } else {echo " ";} ?>"></td>
				</tr>
				<tr valign="top" bgcolor="#eeeeee">
					<td align="right" width="200px">(B) Multiply (A) X 0.32 = GDS</td>
					<td><input type="text" size="10" value="<?php if($GDS){ echo round($GDS, 2); } else {echo " ";} ?>"></td>
				</tr>
				<tr><td><input type="submit" value="Calculate GDS"></td></tr>
			</table>
		</form>
	<?php
	if (($_REQUEST['form_complete2'])) {
						$fpay          = $_REQUEST['pay'];
						$fcar          = $_REQUEST['car'];
						$floan         = $_REQUEST['loan'];
						$fcredit       = $_REQUEST['credit'];
						$fodebt        = $_REQUEST['odebt'];

						$form_complete  = $_REQUEST['form_complete'];

						$pay = preg_replace('/\D/', '', $fpay);
						$car = preg_replace('/\D/', '', $fcar);
						$loan = preg_replace('/\D/', '', $floan);
						$credit = preg_replace('/\D/', '', $fcredit);
						$odebt = preg_replace('/\D/', '', $fodebt);


						$ttl_pay2 = $ttl_pay;	
						$ttl_debt = $car+$loan+$credit+$odebt;

						if ($ttl_debt) {
							if ($pay) {
								$TDS = $ttl_debt/$pay;
							}
							else {$pay = $_REQUEST['pay'];}
						}							
					}
	?>
	<form method="GET" name="TDS-info" action="http://www.realestatebram.com/WP/?page_id=118">
					<input type="hidden" name="form_complete2" value="1">
					<table cellpadding="2" cellspacing="0" border="0" width="100%" align="center">
						<tr valign="top" bgcolor="#cccccc">
							<td align="center" colspan="2"><b>TDS Calculator</b></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee"><td colspan="2"> </td></tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Total Monthly Income, (A) from GDS Calculator</td>
							<td><input type="text" size="10" name="pay" value="<?php if($ttl_pay){ echo $ttl_pay; } elseif ($pay){ echo $pay; } else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Monthly car loan or lease payment</td>
							<td><input type="text" size="10" name="car" value="<?php if($car){echo $car;} else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Monthly loan or line of credit payment</td>
							<td><input type="text" size="10" name="loan" value="<?php if($loan){echo $loan;} else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Monthly credit card payment</td>
							<td><input type="text" size="10" name="credit" value="<?php if($credit){echo $credit;} else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Other monthly payment(s)</td>
							<td><input type="text" size="10" name="odebt" value="<?php if($odebt){echo $odebt;} else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Your total monthly debt payments amount to</td>
							<td><input type="text" size="10" name="ttl_debt" value="<?php if($ttl_debt){ echo $ttl_debt; } else {echo " ";} ?>"></td>
						</tr>
						<tr valign="top" bgcolor="#eeeeee">
							<td align="right" width="200px">Your TDS is</td>
							<td><input type="text" size="10" name="TDS" value="<?php if($TDS){ echo round($TDS, 2); } else {echo " ";} ?>"></td>
						</tr>							
						<tr><td><input type="submit" value="Calculate TDS"></td></tr>
					</table>
				</form>                
            </div>
        
        <?php endwhile; endif; ?>
    
    </article>
    
    <?php get_sidebar(); ?>

<?php get_footer(); ?>

 

I spoke with the theme dev who offered this:

 

Take a look at template_contact.php its got a ajax process on it, you

could duplicate that for your calcs

 

here is the template_contact.php

<?php
/*
Template Name: Contact
*/
?>

<?php get_header(); ?>

    <article id="leftcol" class="left">

	<?php if ( have_posts() ) : while ( have_posts() ) : the_post(); ?>
        	
            <?php ct_first_image_blog(); ?>
            
            <div id="article">
                <div id="formwrap" class="left">
				<?php the_content(); ?>
                    
                    <form id="contactform" class="formular" method="post">
                        <fieldset>
                            <input type="text" name="name" id="name" class="validate[required,custom[onlyLetter]] text-input" value="Name" onfocus="if(this.value=='Name')this.value = '';" onblur="if(this.value=='')this.value = 'Name';" />
                            
                            <input type="text" name="email" id="email" class="validate[required,custom[email]] text-input" value="Email" onfocus="if(this.value=='Email')this.value = '';" onblur="if(this.value=='')this.value = 'Email';" />
                            
                            <textarea class="validate[required,length[2,500]] text-input" name="message" id="message" rows="5" cols="10"></textarea>
                            
                            <input type="hidden" id="ctyouremail" name="ctyouremail" value="<?php echo get_option("ct_your_email", $single = true); ?>" />
                            <input type="hidden" id="ctsubject" name="ctsubject" value="<?php echo get_option("ct_subject", $single = true); ?>" />
                            
                            <input type="submit" name="Submit" value="Submit" id="submit" class="btn" />  
                        </fieldset>
                    </form>
                </div>
                  
                <?php if(get_option("ct_gmap", $single = true) =="yes") { ?>
                <?php contact_us_map(); ?>
                <?php } ?>
            </div>
        
        <?php endwhile; endif; ?>
    
    </article>
    
    <?php get_sidebar(); ?>

<?php get_footer(); ?>

 

Please help me

 

Link to comment
https://forums.phpfreaks.com/topic/224869-php-wp-please-help/
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.