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 Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

querystring to read in php file

Status
Not open for further replies.

rachelason

Programmer
Jun 28, 2004
114
GB
HI! This is the first time i am using this forum. I have to use php to integrate my system with the online banking and i should say i don't know anything about PHP.
Can someone please tell me how to read a querystring variable in a php page.
Buypage.html
<a href="/ssl/content/buyredirect.php?oid=200&total=100" class="suinput">Click here to continue</a>

buyredirect.php....
how do i access the oid and total.

thanks in advance.
Rach
 
Hi ! thanks for that. Is there any other way i can send information from .html to .php?
Thanks.
Rach
 
You can create a form and send it via post method (and access the variables with $_POST[] respectively).
 
HI! i have attached the code. THe oid and total are not passed on to the buyredirect page for some reason.
The code inside << >> is htmlos...there is no problem with that. But the php page is not picking up the value.
Thanks in advance.

buypage.html
<body>
<form name="buyconfirm" action="buyconf" method="post">
<table width="100%" cellpadding="0" cellspacing="0" bgcolor="#FFFFFF" border="0">
<tr><td height="50">The total purchase amt is GBP£<<totalamt>></td></tr><tr><td>
If you would like to continue click on 'BUY'</td></tr>
</td></tr><tr><td><input type="hidden" name="oid" value="<<orderid>>" ><input type="hidden" name="total" value="<<totalamt>>">
<a href="/ssl/content/buyredirect.php">BUY</a>
<a href="javascript:window.close();" class="suinput">CLOSE</a>
</td></tr></table></form></body>

buyredirect.php
<?php
#the following function performs a HTTP Post and returns the whole response
function pullpage( $host, $usepath, $postdata = "" ) {
# open socket to filehandle(epdq encryption cgi)
$fp = fsockopen( $host, 80, &$errno, &$errstr, 60 );
#check that the socket has been opened successfully
if( !$fp ) {
print "$errstr ($errno)<br>\n"; }
else {
#write the data to the encryption cgi
fputs( $fp, "POST $usepath HTTP/1.0\n");
$strlength = strlen( $postdata );
fputs( $fp, "Content-type: application/x- );
fputs( $fp, "Content-length: ".$strlength."\n\n" );
fputs( $fp, $postdata."\n\n" );
#clear the response data
$output = "";
#read the response from the remote cgi
#while content exists, keep retrieving document in 1K chunks
while( !feof( $fp ) ) {
$output .= fgets( $fp, 1024); }

#close the socket connection
fclose( $fp); }
#Ireturn the response
return $output; }
#define the remote cgi in readiness to call pullpage function
$server="someserver";
$url="/someurl";
#the following parameters have been obtained earlier in the merchant's webstore
#clientid, passphrase, oid, currencycode, total

$params="&oid=$oid";
$params.="&total=$total";
#perform the HTTP Post
$response = pullpage( $server,$url,$params );
#split the response into separate lines
$response_lines=explode("\n",$response);

#for each line in the response check for the presence of the string ‘epdqdata’
#this line contains the encrypted string
$response_line_count=count($response_lines);
for ($i=0;$i<$response_line_count;$i++){
if (preg_match('/epdqdata/',$response_lines[$i])){
$strEPDQ=$response_lines[$i]; } }
?>
<html><head><title>SendPHP</title></head><body >
<FORM action="someurl" name="epdqphp" method="POST">
<?php print "$strEPDQ"; ?> <INPUT type="hidden" name="returnurl" value="someurl">
<INPUT type="hidden" name="merchantdisplayname" value="mystore">
<INPUT TYPE="submit" VALUE="purchase"> </FORM> </body></html>
 
btw, the error message 'no encrypted data' and if i view the source of the .php file, $strEPDQ is empty...tooks like the oid and total is empty....
any clue?
rach
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top