I have a PayPal button I need to say "Sold Out" after clicking on it. When the button is click on the shopping cart, I need to run PHP code that adds "M1" to a file "trackOrder.txt". Then it checks the file for the string "M1". I will have other buttons will record to this file as well.
I need help combining this together so it functions. I currently initiating onmouseover for testing purposes.
<!--Calls Javascript test function-->
<form onmouseover="javascript:test()"; target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="business" value="XXXXXXXXXXXXX">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="add" value="1">
<input type="hidden" name="item_name" value="Men Accessory 1">
<input type="hidden" name="amount" value="5.00">
<input type="hidden" name="currency_code" value="USD">
Shipping Options:<br/>
<select name="handling_cart">
<option value="0.00">Free Local Pickup at our store</option>
<option value="3.00">Standard Shipping - $3.00</option>
</select>
<br/>1 available</br>
<input type="image" name="submit" src="http://charitysboutique.com/webpics/addtocart.gif" alt="Add to Cart">
<img alt="" width="1" height="1" src="https://www.paypalobjects.com/en_US/i/scr/pixel.gif">
</form>
<?php
function run(){
$purchasedItem = "M1\n";
$trackFile = fopen("trackOrder.txt", "a+");
$txt = $purchasedItem;
fwrite($trackFile, $txt);
fclose($trackFile);
echo "Finished";
}
?>
<!--Calls PHP run function-->
<script>
function test() {
<?php run();?>
alert("function test has been called")
}
</script>
<!--open and read file-->
<?php
$trackFile = fopen("trackOrder.txt", "r");
if( strpos(file_get_contents("trackOrder.txt"),"M1") !== false) {
echo "Found text";
}
fclose($trackFile);
?>