Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Putting PHP vars into html file
Old 04-25-2009, 03:55 PM Putting PHP vars into html file
Jasonpv's Avatar
Super Talker

Posts: 102
Trades: 0
I'll try to explain what I am trying to accomplish to the best of my ability. I am basically using NuSOAP to get quotes from a quote engine. I can receive, parse and format the data to my liking but am trying to figure out a clever way to get my variable values into my html page? Is there an easy way to go about doing this??

Here is my code:

Code:
<?php
/******************************************************************************************************
	Author: Jason Viafora
	Date: 4/24/2009
	Description: Sends SOAP request to SAS and formats the resopnse 
	
******************************************************************************************************/




//form vars
$state = $_POST['state'];
$tobacco = $_POST['tobacco'];
$gender = $_POST['gender'];
$email = $_POST['email'];
$coverage = $_POST['coverage_amt'];
$month = $_POST['dob_month'];
$day = $_POST['dob_day'];
$year = $_POST['dob_year'];
echo "test2";
require_once('generate_soap.php');
	
		$soapaction = "https://secure.sas-it.com/webservices2/SmartLifeQuoteWebService/GetRatesFromCriteria";
		$client = new nusoap_client('https://secure.sas-it.com/webservices2/SmartLifeQuoteWebService/SmartLife.asmx');
		
		$mysoapmsg = $client->serializeEnvelope('<?xml version="1.0" encoding="utf-8"?>
		<soap:Envelope xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:soap="http://schemas.xmlsoap.org/soap/envelope/">
		  <soap:Body>
			<GetRatesFromCriteria xmlns="https://secure.sas-it.com/webservices2/SmartLifeQuoteWebService/">
			  <AgentKey>{ADA96C52-1FC8-4BCA-BE4F-E8143938CDBD}</AgentKey>
			  <CustomerState>'.$state.'</CustomerState>
			  <TobaccoUser>'.$tobacco.'</TobaccoUser>
			  <CustomerGender>'.$gender.'</CustomerGender>
			  <FaceAmt>'.$coverage.'</FaceAmt>
			  <CustomerDOB>'.$month.$day.$year.'</CustomerDOB>
			  <CustomerEmail>'.$email.'</CustomerEmail>
			  <IpAddress></IpAddress>
			  <URLReferrer></URLReferrer>
			  <AgentRefNumber>000006456-068-082</AgentRefNumber>
			  <ROI></ROI>
			</GetRatesFromCriteria>
		  </soap:Body>
		</soap:Envelope>
			','',array(),'document', 'literal');
		
		
		
		$err = $client->getError();
		if ($err) {
			echo '<h2>Constructor error</h2><pre>' . $err . '</pre>';
		}
		
		$response = $client->send($mysoapmsg, $soapaction);
		// Check for a fault
		if ($client->fault) {
			echo '<h2>Fault</h2><pre>';
			print_r($result);
			echo '</pre>';
		} else {
			// Check for errors
			$err = $client->getError();
			if ($err) {
				// Display the error
				echo '<h2>Error</h2><pre>' . $err . '</pre>';
			} else {
				// Display the result
				/*echo '<h2>Result</h2><pre>';
				print_r($response);
				echo '</pre>';*/
				
				
				$getrates_array = $response["GetRatesFromCriteriaResult"]["diffgram"]["Rates"]["Term"];
				
				/*$array_size = count($getrates_array);
				echo "Array Size: ".$array_size.'<br>';*/
				
				$table = makeTable($getrates_array);
				
				makeHTML($table);	
			}
		}
		
	

	
	/*echo '<h2>Request</h2><pre>' . htmlspecialchars($client->request, ENT_QUOTES) . '</pre>';
	echo '<h2>Response</h2><pre>' . htmlspecialchars($client->response, ENT_QUOTES) . '</pre>';
	echo '<h2>Debug</h2><pre>' . htmlspecialchars($client->debug_str, ENT_QUOTES) . '</pre>';*/
	
	//loop to build table
	function makeTable($array){
		$i = 0;
		foreach ($array as $key => $val){
			$j = 0;
			foreach($val as $k => $v){
				$table[$i][$j] = $v;
				$inner_tr[$i] .= "$v<br>";
				$j++;
			}
			$td .= "<td>$inner_tr[$i]</td>";
			$i++;
		}
		
		$html = "<table><tr>$td</tr></table>";	
		return $table;	
	}
?>

Last edited by Jasonpv; 04-25-2009 at 03:59 PM..
Jasonpv is offline
Reply With Quote
View Public Profile
 
 
Register now for full access!
Old 04-26-2009, 10:37 AM Re: Putting PHP vars into html file
moatist's Avatar
Skilled Talker

Posts: 64
Trades: 0
You could always modify your .htaccess file to allow PHP to parse in HTML files.

Add the following lines to .htaccess file:

Code:
RemoveHandle .html .htm
AddType application/x-httpd-php .php .htm .html
-Moatist
__________________
Think in code; Dream in digital.

<?php if($helpfull == true){ $talkupation++; } ?>
moatist is offline
Reply With Quote
View Public Profile
 
Old 04-26-2009, 03:23 PM Re: Putting PHP vars into html file
nayes84's Avatar
Extreme Talker

Latest Blog Post:
Difference between ASP And JSP
Posts: 232
Name: John
Location: Tokyo
Trades: 0
or you can use mod rewrite in .htaccess file
Code:
RewriteEngine On
RewriteRule ^(.*)\.html$ $1.php [L]
__________________

Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE
|
Please login or register to view this content. Registration is FREE

if(I'm("Helpful")) Add_Talkupation("nayes84");
nayes84 is offline
Reply With Quote
View Public Profile
 
Reply     « Reply to Putting PHP vars into html file
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.78704 seconds with 12 queries