I'm trying to create a form in PHP that pulls data from a web service and displays it under the form in XML.
This project is for my internship and the web service pulls info from a DVD rental company.
So far my form has one UPC number hard-coded into it and when you click submit you another get one result (see http://mondo247.com/rndb/rndbTEST/xmlEX/index14.php).
I want to set any UPC number entered into the form (on index14.php) to be passed as a variable into the XML web page (like "<UPC>".$upc."</UPC>" for example) named data14.php.
My code for both pages is below (everything is real except for the web services URL):
<?php
//index14.php
session_start();
$_SESSION['rnid']='2341';
$_SESSION['rncert']='5E95798A20D9745B67FAFC3661A3EE5C0C5BDF95';
$_SESSION['transType']='GETUPCINVENTORY';
//$_SESSION['upc']='014381501322';
//$_SESSION['upc'] == $_POST['upc'];
$_SESSION['upc'] == $upc;
$_SESSION['itemDetails']='TRUE';
?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en_US" xml:lang="en_US">
<head>
<title>XML Data Request</title>
</head>
<body>
<h2>RetailNet Database Test Page from Matt</h2>
<form method="post" action="<?php echo $_SERVER['PHP_SELF'] ?>?go" id="searchForm" name="searchForm">
<input type="text" size="20" maxlength="40" name="upc" value="014381501322" /> <a href="<?=$_SERVER['PHP_SELF']?>">Back to Search Page Start</a>
<br />
<input type="submit" id="submit" name="submit" value="Submit" />
</form>
<?php
$queryString = $_SERVER["QUERY_STRING"];
if ($queryString == 'go') { ?>
<?php
function postHttps($url, $request) {
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_POST, 1) ;
curl_setopt($ch, CURLOPT_POSTFIELDS, $request);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
$result = curl_exec($ch);
curl_close($ch);
return $result;
}
?>
<?php
echo postHttps("https://webservice.exe", utf8_encode(file_get_contents("data14.php")));
?>
<?php } ?>
<br />
<br />
</body>
</html>
<?php
//data14.php
session_start();
?>
<?php
$xml_output = "<?xml version=\"1.0\"?>\n";
$xml_output .= "<TRANSACTION>";
$xml_output .= "<RNID>2341</RNID>";
$xml_output .= "<RNCERT>5E95798A20D9745B67FAFC3661A3EE5C0C5BDF95</RNCERT>";
$xml_output .= "<TRANSACTIONTYPE>GETUPCINVENTORY</TRANSACTIONTYPE>";
$xml_output .= "<UPC>014381501322</UPC>";
$xml_output .= "<SHOWITEMDETAILS>TRUE</SHOWITEMDETAILS>";
$xml_output .= "</TRANSACTION>";
echo $xml_output;
?>
Thanks for the help!:p