www.webdeveloper.com
Results 1 to 3 of 3

Thread: Pass Form Variable to Another Web Page

Threaded View

  1. #1
    Join Date
    Apr 2008
    Location
    Seattle, WA
    Posts
    19

    Pass Form Variable to Another Web Page

    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 Code:
    <?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"  /> &nbsp;&nbsp;<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($chCURLOPT_URL$url);
            
    curl_setopt($chCURLOPT_RETURNTRANSFER1);
            
    curl_setopt($chCURLOPT_POST1) ;
            
    curl_setopt($chCURLOPT_POSTFIELDS$request);
            
    curl_setopt($chCURLOPT_SSL_VERIFYPEER0);
            
    curl_setopt($chCURLOPT_SSL_VERIFYHOST0);
            
    $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 Code:
    <?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!
    Last edited by risingPhoenix; 10-24-2008 at 02:18 AM.

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
HTML5 Development Center



Recent Articles