Hi I have made a price calculator which calculates the deposit due by players of my service, how can I link this to paypal so that I have a paypal 'Pay now' button that would open a page with correct amount passed in Euros and option to pay by credit card or paypal? Thanks
Frontend.php
Ajax.phpCode:<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <script language="javascript" src="ajax.js"></script> </head> <body> <p style="display: inline;">Number of players:</p> <input type="text" id="num1" size="2"> <input type="button" value=" = " onClick="doMath();"> <div id="answer" style="display: inline; font-size: 16px"></div> </body> </html>
Backend.phpCode:http = getHTTPObject(); function getHTTPObject(){ var xmlhttp; /*@cc_on @if (@_jscript_version >= 5) try { xmlhttp = new ActiveXObject("Msxml2.XMLHTTP"); }catch(e){ try{ xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); }catch(E){ xmlhttp = false; } } @else xmlhttp = false; @end @*/ if(!xmlhttp && typeof XMLHttpRequest != 'undefined'){ try { xmlhttp = new XMLHttpRequest(); }catch(e){ xmlhttp = false; } } return xmlhttp; } function doMath(){ var url = "backend.php?num1=" + document.getElementById('num1').value; http.open("GET", url, true); http.onreadystatechange = handleHttpResponse; http.send(null); } function handleHttpResponse(){ if(http.readyState == 4){ document.getElementById('answer').innerHTML = http.responseText; } }
Code:<?php if($_GET['num1']==""){ echo "Please enter number of players"; exit; } if(!is_numeric($_GET['num1'])){ echo "Error: Invalid numbers."; exit; } echo $_GET['num1'] * 7; ?>







Bookmarks