Page 1 of 1

Help with UDT

Posted: Thu May 17, 2012 7:44 am
by dinmix
I'm trying to create a UDT for a form but I am stuck here. Appreciate if anyone can help. The original code are like the following:

Code: Select all

<input type=hidden name="cartId" value="echo'$Price['bookingid']; ">'
<input type=hidden name="name" value="<? echo $Price['fullname']; ?>">
I cant get this to work:

Code: Select all

echo'<input type=hidden name="name" value="<? echo $Price['fullname']; ?>"';
Also, I am not sure if I add echo infront of the script tag like the following in red.

Code: Select all

echo'<__script__ language="JavaScript" src="https://www.worldpay.com/cgenerator/cgenerator.php?instId=123456"></__script>';
Can anyone show me what is the correct way of doing this? Thank you

Re: Help with UDT

Posted: Thu May 17, 2012 8:41 am
by hasanen
I think it should be like:

Code: Select all

echo '<input type=hidden name="cartId" value="' . $Price['bookingid'] . '" />
<input type=hidden name="name" value="' .  $Price['fullname'] . '" />';
Although I prefer:

Code: Select all

echo sprintf('<input type=hidden name="cartId" value="%s" />
<input type=hidden name="name" value="%s" />',  $Price['bookingid'] , $Price['fullname']); 
If I remember right, you can't use "<?php" and "?>" tags in UDT. It's pure php. You could test your UDTs by making eg. form.php, write your code there and finally copy/paste the code to UDT (remberer to strip those "<?php" and "?>" tags).

Re: Help with UDT

Posted: Thu May 17, 2012 10:14 am
by Jos

Code: Select all

echo '<input type="hidden" name="name" value="' . $Price['fullname'] . '" />';

Re: Help with UDT

Posted: Thu May 17, 2012 7:25 pm
by dinmix
Thank you guys, I will try that.