I have just a quick question. i was using a normal html link tag to redirect to a paypal checkout page and it was working fine even when i had php inside the url. but when i was using it in a php header
the url cuts off where i enter the php.
header('location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXX&lc=UK&item_name=<? echo $product . " " . $server ?>&amount=<? echo $xprice1; ?>%2e00¤cy_code=GBP&button_subtype=services&no_note=0&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest');
You are placing the PHP code inside of the location redirect as a string. The code is not being evaluated as PHP.
Try this instead:
<?php
$url = "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXX&lc=UK&item_name=" . $product . " " . $server ."&amount=" . $xprice1 . "%2e00¤cy_code=GBP&button_subtype=services&no_note=0&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest";
header('location: ' . $url);
Or, you could keep it in one line like so:
<?php
header('location: ' . "https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXX&lc=UK&item_name=" . $product . " " . $server ."&amount=" . $xprice1 . "%2e00¤cy_code=GBP&button_subtype=services&no_note=0&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest");
header('location: https://www.paypal.com/cgi-bin/webscr?cmd=_xclick&business=XXXX&lc=UK&item_name=<? echo $product' . " " . '$server ?>&amount=<? echo $xprice1; ?>%2e00¤cy_code=GBP&button_subtype=services&no_note=0&bn=PP%2dBuyNowBF%3abtn_buynowCC_LG%2egif%3aNonHostedGuest');
This may solve your problem. Please dont forget to tick the answer right if it works.
Related
I'm setting a variable based on an array. When I echo the variable it displays on the screen, however when I try to add it to a Header Location it doesn't show up in the URL of the next page - everything else does:
$myid = $selected_cat3[0]['id'];
Header("Location:/cat-dashboard/cat-results/?catID=" . $myid
. "&question1=" . $_GET['question1'] . "&question2=" . $_GET['question2']
. "&question3=" . $_GET['question3'] . "&question4=" . $_GET['question4']
. "&question5=" . $_GET['question5'] . "&question6=" . $_GET['question6']
. "&question7=" . $_GET['question7'] . "&question8=" . $_GET['question8']);
This is the generated url:
/cat-dashboard/cat-results/?catID=&question1=0&question2=3&question3=1&question4=1&question5=1&question6=2&question7=1&question8=3
Am I doing something wrong? It doesn't show even if I use: $myid = "1";
I am having trouble getting the URL to display correctly. This works now, but the link has " in front of the url. and yet the url link works fine
echo "<br>" . $result['text'] . " <em>(Contributed by: \"<a
href=\"http://example.com/portfolio?ID=$result[ID]\">" .
$result['display_name'] . "</a>" . ")</em>" . "<br>";
sigh:
echo '<br>' . $result['text'] . ' <em>(Contributed by: <a
href="http://example.come/portfolio?ID="'.$result['ID'].'">'.
$result['display_name'] .'</a>)</em><br>';
http://www.reecemcmillin.com/albums/
<?php
$uncut = file_get_contents('http://www.google.com/#sclient=psy-ab&hl=en&safe=active&source=hp&q=' . $_POST['band'] . '+' . $_POST['album'] . '+zip+inurl:mediafire');
$strip1 = strstr($uncut, 'www.mediafire.com/?');
$link = substr($strip1, 0, 30);
echo $link;
?>
It doesn't seem to be writing the website content to $uncut. Can somebody help me figure out what's wrong? Thanks.<3
Clients are not supposed to send URI-fragments (the portion of the URI following #) to servers when they retrieve a document. PHP is probably sending a request for the google homepage, effectively: file_get_contents('http://www.google.com/');. If you echo $uncut, that's probably what you'll see you're getting back.
Try a querystring-based URI instead.
<?php
$uncut = file_get_contents('http://www.google.com/search?sclient=psy-ab&hl=en&safe=active&source=hp&q=' . urlencode($_POST['band']) . '+' . urlencode($_POST['album']) . '+zip+inurl:mediafire');
I have a huge list of stuff for a glossary ( about 17 pages worth ) that I have to put into an XML file. So I decided I'd use php to make it. My code works, except where ALL the XML code is, it doesn't show because it's trying to render it. Help?
$arg=explode("\n", $strang);
echo count($arg);
for ($i=0;$i<=count($arg);$i=$i+3)
{
echo "<word id='" . $arg[$i+1] . "'>";
echo "<desc>" . $arg[$i] . " - " . $arg[$i+2] . "</desc>";
echo "<pic></pic>";
echo "<audio></audio>";
}
I assume by render it you mean in your browser? If so, you'll need to escape the characters so they will be interpreted literally rather than as markup.
Check out htmlspecialchars and htmlentities
use CDATA construction:
echo "<desc><![CDATA[" . $arg[$i] . " - " . $arg[$i+2] . "]]></desc>";
If this is your entire script, fastest way would probably be to swap all of the <'s with <
$arg=explode("\n", $strang);
echo count($arg);
for ($i=0;$i<=count($arg);$i=$i+3)
{
echo "<word id='" . $arg[$i+1] . "'>";
echo "<desc>" . $arg[$i] . " - " . $arg[$i+2] . "</desc>";
echo "<pic></pic>";
echo "<audio></audio>";
}
I have a mySQL table loaded with 50 rows. Each row has the necessary information to process a credit card. When the user clicks on Process Credit Cards, query the table and display each row on the page using html. Once the data has been displayed on the page a scrip would begin to process each row through the merchant account and turn the corresponding row either red for decline or green for approve without refreshing the page after each transaction. I think I need to use AJAX or jQuery to make this happen but I'm not sure I'm headed in the right direction. Here is the script to process the transactions:
<?php
$request = new GatewayRequest();
$response = new GatewayResponse();
$service = new GatewayService();
$request->Set(GatewayRequest::MERCHANT_ID(), "111111111111111");
$request->Set(GatewayRequest::MERCHANT_PASSWORD(), "xxxxxxxxxxxx");
$time = time();
$request->Set(GatewayRequest::MERCHANT_CUSTOMER_ID(), $time . '.PHPTest');
$request->Set(GatewayRequest::MERCHANT_INVOICE_ID(), $time . '.SaleTest');
$request->Set(GatewayRequest::AMOUNT(), "9.99");
$request->Set(GatewayRequest::CARDNO(), "4111111111111111");
$request->Set(GatewayRequest::EXPIRE_MONTH(), "02");
$request->Set(GatewayRequest::EXPIRE_YEAR(), "2010");
$request->Set(GatewayRequest::CVV2(), "999");
$request->Set(GatewayRequest::CUSTOMER_FIRSTNAME(), "Joe");
$request->Set(GatewayRequest::CUSTOMER_LASTNAME(), "PHPTester");
$request->Set(GatewayRequest::EMAIL(), "phptest#fakedomain.com");
$request->Set(GatewayRequest::IPADDRESS(), $_SERVER['REMOTE_ADDR']);
$request->Set(GatewayRequest::BILLING_ADDRESS(), "123 Main St");
$request->Set(GatewayRequest::BILLING_CITY(), "Las Vegas");
$request->Set(GatewayRequest::BILLING_STATE(), "NV");
$request->Set(GatewayRequest::BILLING_ZIPCODE(), "89141");
$request->Set(GatewayRequest::BILLING_COUNTRY(), "US");
$request->Set(GatewayRequest::SCRUB(), "IGNORE");
$request->Set(GatewayRequest::CVV2_CHECK(), "IGNORE");
$request->Set(GatewayRequest::AVS_CHECK(), "IGNORE");
$service->SetTestMode(TRUE);
if ($service->PerformPurchase($request, $response)) {
print "Purchase succeeded\n";
print "Response Code: " .
$response->Get(GatewayResponse::RESPONSE_CODE()) . "\n";
print "Reasone Code: " .
$response->Get(GatewayResponse::REASON_CODE()) . "\n";
print "Auth No: " . $response->Get(GatewayResponse::AUTH_NO()) . "\n";
print "AVS: " . $response->Get(GatewayResponse::AVS_RESPONSE()) . "\n";
print "CVV2: " . $response->Get(GatewayResponse::CVV2_CODE()) . "\n";
print "GUID: " . $response->Get(GatewayResponse::TRANSACT_ID()) . "\n";
print "Account: " .
$response->Get(GatewayResponse::MERCHANT_ACCOUNT()) . "\n";
print "Scrub: " .
$response->Get(GatewayResponse::SCRUB_RESULTS()) . "\n";
} else {
print "Purchase failed\n";
print "GUID: " . $response->Get(GatewayResponse::TRANSACT_ID()) . "\n";
print "Response Code: " .
$response->Get(GatewayResponse::RESPONSE_CODE()) . "\n";
print "Reasone Code: " .
$response->Get(GatewayResponse::REASON_CODE()) . "\n";
print "Exception: " .
$response->Get(GatewayResponse::EXCEPTION()) . "\n";
print "Scrub: " .
$response->Get(GatewayResponse::SCRUB_RESULTS()) . "\n";
}
?>
Will this type of code work with AJAX or jQuery without being rewritten? Any help would be appreciated.
Anything can be made to work without being rewritten, but you've set yourself up for a lot of headaches there. You'll probably have much better luck (and save yourself tons of time) by formatting all those print statements into an array and JSON encoding it. Obviously javascript loves JSON.