I want to send the total from my shopping cart to paypal but nothing seems to work.When you get to the paypal page it's just blank.I can't seem to get my paypal.php page to pick up the total.
This is the code from the checkout page below
Code: Select all
<?php
<?php
session_start();
include "header.inc.php";
$ttl_hal="Cart";
require "shop_menu.inc.php";
$arr_item=explode("|",$myshop);
?>
<table border=0 cellspacing=0 cellpadding=0 width=100%><tr><td class=black>
<!-- START CONTENTS -->
<script Language = JavaScript>
function input_verify(thisform)
{
if (thisform.fnama.value=="")
{
alert("Please fill your name")
thisform.fnama.focus()
thisform.fnama.select()
return false
}
if (thisform.falamat.value=="")
{
alert("Please fill your address")
thisform.falamat.focus()
thisform.falamat.select()
return false
}
if (thisform.ftelpon.value=="")
{
alert("Please fill your phone number")
thisform.ftelpon.focus()
thisform.ftelpon.select()
return false
}
if (thisform.falt_email.value=="")
{
alert("Please fill your email")
thisform.falt_email.focus()
thisform.falt_email.select()
return false
}
}
function setharga(){
thisform.lbharga.value=thisform.selharga.options[selharga.selectedIndex].value;
}
</script>
<form method="POST" action="paypal.php" onsubmit="return input_verify(this);">
<h3>Your Order Items</h3>
<?php
$total=0;
$subtotal=0;
if (!empty($myshop)){
echo "<table border=0 cellspacing=1 cellpadding=4 class=black width=100%>";
echo "<tr bgcolor=#CCCCCC><td><b>Picture</td><td><b>Name</td><td><b>Price<br>(conversion)</td><td><b>Qty</td><td><b>Subtotal(".$defcurr.")</td></tr>";
for ($co=1; $co<count($arr_item); $co++){
$item_picture="";
$item_title="";
$item_description="";
$item_price="";
$ro_shop=explode(":",$arr_item[$co]);
$rs_item=@mysql_query("select * from shop_item where id='$ro_shop[0]'");
$ada_item=@mysql_num_rows($rs_item);
if ($ada_item>0){
$item_picture=@mysql_result($rs_item,0,"picture");
$item_title=@mysql_result($rs_item,0,"title");
$item_description=@mysql_result($rs_item,0,"description");
$item_curr=@mysql_result($rs_item,0,"curr");
$item_price=@mysql_result($rs_item,0,"price");
$item_disc=@mysql_result($rs_item,0,"discount");
}
echo "<tr>";
echo "<td>";
if ( (!empty($item_picture)) and (file_exists($item_picture)) ){
echo "<img src='".$item_picture."' border=0 width=50 height=50>";
}
echo "</td>";
echo "<td><b>".$item_title."</b>";
echo "</td>";
echo "<td align=right>";
if (!empty($item_disc)){
echo "<font color=#FF0000>".$item_curr." <strike>".number_format($item_price, 2)."</strike></font>";
echo "<br><font color=#008080>Disc: ".$item_disc."%</font>";
$item_price=$item_price - ($item_price*($item_disc/100));
echo "<br>".$item_curr." ".number_format($item_price, 2);
} else {
echo $item_curr." ".number_format($item_price, 2);
}
if ($defcurr<>$item_curr){
$curr_from=@mysql_result(@mysql_query("select curr_value from shop_curr where curr_name='$item_curr'"),0,0);
$curr_to=@mysql_result(@mysql_query("select curr_value from shop_curr where curr_name='$defcurr'"),0,0);
$item_price=($item_price*$curr_to)/$curr_from;
// echo "$curr_from | $curr_to";
echo "<br>(".$defcurr." ". number_format($item_price,2).")";
}
echo "</td>";
echo "<td align=right>";
echo $ro_shop[1];
echo "</td>";
$subtotal=$ro_shop[1]*$item_price;
echo "<td align=right><b>".number_format($subtotal, 2)."</td>";
echo "</tr>";
$total=$total+$subtotal;
}
echo "<tr><td bgcolor=#CCCCCC colspan=4 align=right><b>T O T A L</td>";
echo "<td bgcolor=#CCCCCC align=right><b>".number_format($total, 2)."</td></tr>";
echo "</table>";
} else {
echo "<div align=center><h3><br>Your Cart is still empty,<br><a href='shop.php' class=black>Have a nice Shop</a>...!</h3></div>";
}
?>
<h3>Delivery Address</h3>
<table border="0" cellpadding="2" cellspacing="0" class=black WIDTH=100%>
<tr>
<td align=right>Full Name:</td>
<td><input type="text" name="fnama" size="20" class=ed></td>
</tr>
<tr>
<td align=right>Address</td>
<td><textarea rows="3" name="falamat" cols="27" class=ed></textarea></td>
</tr>
<tr>
<td align=right>Postal Code</td>
<td><input type="text" name="fkodepos" size="9" class=ed></td>
</tr>
<tr>
<td align=right>City</td>
<td><input type="text" name="fkota" size="20"></td>
</tr>
<tr>
<td align=right>Province</td>
<td><input type="text" name="fpropinsi" size="20"></td>
</tr>
<tr>
<td align=right>Phone</td>
<td><input type="text" name="ftelpon" size="20" class=ed></td>
</tr>
<tr>
<td align=right>Email</td>
<td><input type="text" name="falt_email" size="20" class=ed>
<input type="checkbox" name="ccmail" value="yes" checked><small>Send me Order Copy</small>
</td>
</tr>
<tr>
<td align=right>Your Note</td>
<td><textarea rows="3" name="fcatatan" cols="27" class=ed></textarea></td>
</tr>
<tr>
<td align=center colspan=2 bgcolor=#CCCCCC>
<input type="hidden" name="order" value="yes">
<input type="button" value="« Back" name="btcancel" onclick=history.go(-1) class=but>
<input type="submit" value="Finish »" name="btsubmit" class=but></td>
</tr>
</table>
</form>
<!-- END CONTENTS -->
</td></tr></table>
?>I created a page called paypal.php & used the following code..
Code: Select all
<?php
<html>
<body>
<form name= "order" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_ext-enter"><br>
<input type="hidden" name="redirect_cmd" value="_xclick"><br>
<input type="hidden" name="return"
value = "http://<your site>/notify.php?status=T"><br>
<input type="hidden" name="cancel_return"
value = "http://<your site>/notify.php?status=F"><br>
<input type="hidden" name="business" value ="s@S">
<input type="hidden" name="item_name" value="your product">
<input type="hidden" name="shipping" value="0.00">
<input type="hidden" name="shipping2" value="0.00">
<!-- end of form -->
<?php
//get values from previous page
$item_price = $HTTP_GET_VARS['total'];
echo "<input type="hidden" name="total" value="$total"><br>\n";
?>
</form>
<script type="text/javascript" language="JavaScript">
//submit form
document.order.submit();
</script>
</body>
<html>
?>I've looked at the way paypal say to do it & they use 'amount' in their script & say you can't change it.What am I doing wrong?