Page 1 of 1

Is it possible??

Posted: Wed Jan 20, 2010 1:24 pm
by iant
Hi,

I have been learning PHP for the last month and have hit a problem, I need to insert a PHP form into a PHP script.

PHP Script "Form in here" shows where i need to insert the code.

Code: Select all

$out.="<a rel=\"lightbox[".$gal."]\" title=\"$file\" href=\"$gal/$file\" paypalform=\"FORM IN HERE\">";
$out.="<img src=\"thumbs/".createThumb( $gal."/".$file, "thumbs/", $width )."\" width=\"$width\" alt=\"".$file."\" class=\"bordered\" /></a>\n";
PayPal Code to be inserted

Code: Select all

<form target="paypal" action="https://www.paypal.com/cgi-bin/webscr" method="post">
<input type="hidden" name="cmd" value="_cart">
<input type="hidden" name="business" value="email@email.com">
<input type="hidden" name="lc" value="GB">
<input type="hidden" name="item_name" value="Pictures">
<input type="hidden" name="item_number" value="999">
<input type="hidden" name="button_subtype" value="products">
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="add" value="1">
<input type="hidden" name="bn" value="PP-ShopCartBF:btn_cart_SM.gif:NonHostedGuest">
<table>
<tr><td><input type="hidden" name="on0" value="Sizes">Sizes</td></tr><tr><td><select name="os0">
    <option value="Small">Small £0.99</option>
    <option value="Medium">Medium £1.99</option>
    <option value="Small">Small £2.99</option>
</select> </td></tr>
</table>
<input type="hidden" name="currency_code" value="GBP">
<input type="hidden" name="option_select0" value="Small">
<input type="hidden" name="option_amount0" value="0.99">
<input type="hidden" name="option_select1" value="Medium">
<input type="hidden" name="option_amount1" value="1.99">
<input type="hidden" name="option_select2" value="Small">
<input type="hidden" name="option_amount2" value="2.99">
<input type="hidden" name="option_index" value="0">
<input type="image" src="https://www.paypal.com/en_GB/i/btn/btn_cart_SM.gif" border="0" name="submit" alt="PayPal - The safer, easier way to pay online.">
<img alt="" border="0" src="https://www.paypal.com/en_US/i/scr/pixel.gif" width="1" height="1">
</form>
Is it possible? and could anyone give me some pointers?

Many Thanks
Ian

Posted: Wed Jan 20, 2010 1:37 pm
by Jonah Bron
You are trying to put an entire form into a fictitious attribute? Why?

Re: Is it possible??

Posted: Wed Jan 20, 2010 1:48 pm
by iant
Hi,

Thanks for your reply.

The script is built into a CMS site which displays galleries with LightBox, The additional "paypalform" is displayed on the bottom of the lightbox window for customers to purchase the picture.

It works prefectly if i paste the html code into the cms, but i want it to add it automatically.

Is there a better way to do it??

Re: Is it possible??

Posted: Wed Jan 20, 2010 2:34 pm
by AbraCadaver
Save the form in a file called 'paypalform.html', then include it:

Code: Select all

// is this something you just made up on your own?  If so, get rid of it.
$out.="<a rel=\"lightbox[".$gal."]\" title=\"$file\" href=\"$gal/$file\" paypalform=\"FORM IN HERE\">";
//
$out.="<img src=\"thumbs/".createThumb( $gal."/".$file, "thumbs/", $width )."\" width=\"$width\" alt=\"".$file."\" class=\"bordered\" /></a>\n";
include 'paypalform.html';