Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Help! Need to include a page which returns results of submitted form, not the form itslef

Status
Not open for further replies.

southbeach

Programmer
Jan 22, 2008
879
US
Sorry for the confusing subject line!

The problem:
I want to load a PHP page and get back what would be the equivalent of having submitted the form within the page, not the form itself ...

I have
Code:
 $filename='/merge/jlweb2php'.rand().'.htm';
 $_SESSION['jlweb']='qual=&name=demo&wxyz=xyz&sys=t3&proc=jlweb&type=view&jlweb_fn=goinput&jlweb_ky='.$string.'&jlweb_ix=C&jlweb_pg='.$filename.'&jlweb_xt=Y';
 $jlweb=getResolved('/merge/push2web.php');

function owcFile($filename,$string) {
//
// Open Write Close File - Given $filename, open $filename with write/append mode then write $string and close $filename...
//
$file=fopen($filename, "a+");		// Open file to write to
$fout=fwrite($file, $string);		// Write line of text with parameters info
close=fclose($file);			// Close file to prevent problems down the road ...
}

function getResolved($page) {
ob_start();
include $page;
$content = ob_get_contents();
ob_end_clean();
return ($content);
}

The code for push2web.php looks like this
Code:
<form name="jlweb" id="jlweb" action="route.cgi" method="post">
<?php
// Lets explode url_string to build an array we can use ...
$formVals = array();
$exp1 = explode('&', $_SESSION['jlweb']);
foreach ($exp1 as $key=>$val) {
list($name,$value)=explode("=", $val);
echo '<input name="'.$name.'" id="'.$name.'" value="'.$value.'" type="text" />';	}
?>
</form>
<script type="text/javascript">
$(document).ready(function(){
     $('#jlweb').submit();
});
</script>

I do not want to see the <form> tag and the <input> tags, I want whatever is returned upon submitting form.

Is this possible?

;-)

Thanks,




--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
can you try explaining again? perhaps with an example mocked up in html of what you want.
 
the page php2web.php parses through the string and it should create a form like
Code:
<form name="jlweb" id="jlweb" action="route.cgi" method="post">
  <input name="name1" id="name1" value="1" />
  <input name="name2" id="name2" value="2" />
  <input name="name3" id="name3" value="3" />
  <input name="name4" id="name4" value="4" />
</form>
The session variable $_SESSION['jlweb'] value normally looks like

name1=value1&name2=value2&name3=value3&name4=value4

route.cgi is a shell script written to parse the QUERY_STRING sent by HTTP Server (Apache) and produces output based on submitted values. The results are then push to standard output using shell script command "echo".

So, under the right conditions, I may get a page that looks like this:

name1:12590.99|name2:0.00|name3:820.55|name4:120.90

The need is having the ability to retrieve data from a non-relational database using an API (route.cgi) WHICH only works if used as if I were submitting an HTML form. This limitation is why I am trying to emulate the form submission and capture the returned values.

Am I doing better?




--
SouthBeach
The good thing about not knowing is the opportunity to learn - Yours truly, 2008.
 
I'm still lost.
Let me try to play it back.

1. You have a known string made up of name"value" pairs separated by an ampersand (Ie the input that you would get from submitting an HTML form using the GET method)

2. You want to create an HTML form on the fly that consists of inputs which have the names and values of your name value string and then autosubmit it to route.CGI.

3. Route.CGI returns some information based on the name value pairs submitted to
it.

4. You want to capture the returned data.

If this is the case then you would be better off using curl than doing item 2.

If you post the code of route.CGI then we can probably rewrite it to use native php which would be an even better solution. Or if route.CGI calls a second function to retrieve data or has a method interface other than Apache then that would also be a better solution than performing an external call to your own servers.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top