Rewrite JavaScript with PHP functions
Posted: Thu May 25, 2006 7:52 am
Weirdan | Please use
In paypal.inc.php :
Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]
I have a web with a shopping cart. This first code is where the client chooses which payment they will use to pay. When choosing "Paypal" this "paypal.inc.php include is called but unfortunately is uses this last line made with JavaScript to submit the paypal details. How can I erase this JS line and write some PHP code instead?
In shopping cart :Code: Select all
switch ($_REQUEST["pmethod"]){
case "Paypal" : include ("processor/paypal.inc.php"); break;
case "BankTransfer" : include ("processor/offline.inc.php"); break;
}Code: Select all
<form name="paypal" action="https://www.paypal.com/cgibin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="upload" value="1">
<input type="hidden" name="currency_code" value="<? echo $paypal_currency; ?>">
<input type="hidden" name="business" value="<? echo $paypal_email; ?>">
<?
// id, description, price, quantity, postage
session_start();
$sessionid = $_SESSION["sessionid"];
$fp = fopen ("./sessions/".$sessionid.".dat", "r+");
$coupon = fgetcsv ($fp, 50);
$x = 1;
while ($data = fgetcsv ($fp, 500)) {
echo "<input type='hidden' name='item_name_$x' value='".$data[1]."'>\n";
echo "<input type='hidden' name='amount_$x' value='".$data[2]."'>\n";
echo "<input type='hidden' name='shipping_$x' value='".$data[4]."'>\n";
echo "<input type='hidden' name='quantity_$x' value='".$data[3]."'>\n";
$x++;
}
fclose ($fp);
?>
</form>
<script>document.paypal.submit();</script>Weirdan | Please use
Code: Select all
,Code: Select all
and [syntax="..."] tags where appropriate when posting code. Your post has been edited to reflect how we'd like it posted. Please read: [url=http://forums.devnetwork.net/viewtopic.php?t=21171]Posting Code in the Forums[/url] to learn how to do it too.[/color]