...

View Full Version : What type of Request is this?



ameenov
05-19-2007, 01:01 PM
I'm a PHP PROGRAMMER & I HAVE THIS FILE IN ASP.
I WANT TO REWRITE IT IN PHP..
I'm TRYING TO UNDERSTAND THIS CODE

---------------------------------------------------

PaymentID = Request("paymentid")
ResultCode = Request("result")
AuthCode = Request("auth")
TranID = Request("tranid")
PostDate = Request("postdate")
TrackID = Request("trackid")

Response.Write("REDIRECT=http://www.domain.com/receipt.php?PaymentID=" & PaymentID)

------------------------------------------------

Is it GET REQUEST?
CAN ANYONE REWRITE THIS SMALL CODE IN PHP?

----------------------
THIS IS MY REWRITING BUT I DON'T KNOW IT IT IS CORRECT





if (isset ($_GET['paymentid'])) { $PaymentID = $_GET['paymentid']; }
if (isset ($_GET['result'])) { $ResultCode = $_GET['result']; }
if (isset ($_GET['auth'])) { $AuthCode = $_GET['auth']; }
if (isset ($_GET['tranid'])) { $TranID = $_GET['tranid']; }
if (isset ($_GET['postdate'])) { $PostDate = $_GET['postdate']; }
if (isset ($_GET['trackid'])) { $TrackID = $_GET['trackid']; }

//---------------------------------------------------------------
if (isset ($_GET['paymentid'])) {

print "<meta http-equiv='refresh' content='0; url='http://www.domain.com/receipt.php?PaymentID=$PaymentID'>";

}
//---------------------------------------------------------------

ess
05-19-2007, 04:26 PM
hello there,

Here is a quick soltuion...and should work with both POST and GET forms


<?php
// variable to hold the page you want to forward to
$forward_to = "http://domainname.co.uk/page.html";
// variable to hold a message in case of an error
$error_message = ":( error...payment id is not specified.";
// get all values using short hand statement
// you should do some validations by the way.
$PaymentID = (isset($_REQUEST['paymentid']) && !empty($_REQUEST['paymentid']) )? $_REQUEST['paymentid'] : "";
$ResultCode = (isset($_REQUEST['result']) && !empty($_REQUEST['result']) )? $_REQUEST['result'] : "";
$AuthCode = (isset($_REQUEST['auth']) && !empty($_REQUEST['auth']) )? $_REQUEST['auth'] : "" ;
$TranID = (isset($_REQUEST['tranid']) && !empty($_REQUEST['tranid']) )? $_REQUEST['tranid']: "";
$PostDate = (isset($_REQUEST['postdate']) && !empty($_REQUEST['postdate']))? $_REQUEST['postdate'] : "";
$TrackID = (isset($_REQUEST['trackid']) && !empty($_REQUEST['trackid']) ) ? $_REQUEST['trackid']: "";
// check if payment id != ""...using strcmp for absolute comparason...
// if you use == sometimes the result is not 100% accurate.
if( strcmp( $PaymentID, "" ) != 0 ){
header( "location: " . $forward_to );
exit();
} else {
echo $error_message;
} //-- ends else
?>

I strongly suggest that you ensure that the data is validated.

Cheers,
Ess

ameenov
05-20-2007, 09:17 AM
Thank you very much my friend .. :thumbsup:




I strongly suggest that you ensure that the data is validated.


I need it working first than validated it.
Now i will validated the rest of the coding ;)



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum