Home › Forums › Archived Forums › Weaver II Theme › Weaver II Pro › Can php script go into a perpage text widget?
- This topic has 18 replies, 4 voices, and was last updated 6 years, 9 months ago by
swmagic999.
-
AuthorPosts
-
September 3, 2015 at 19:32 UTC - Views: 4 #18201
swmagic999
ParticipantI have a form that I’m going to drop into the main html text for use. It looks like this:
<form method=”POST” action=”request.php”>
<label>First Name: <input type=”text” name=”FirstName” value=”Joe”></label><br />
<label>Last Name: <input type=”text” name=”LastName” value=”Cuervo”></label><br />
<label>Address Line 1: <input type=”text” name=”AddressLine1″ value=”123 Main St.”></label><br />
<label>Address Line 2: <input type=”text” name=”AddressLine2″ value=”Suite 1″></label><br />
<label>City: <input type=”text” name=”City” value=”Paterson”></label><br />
<label>State: <input type=”text” name=”State” value=”NJ”></label><br />
<label>Zip: <input type=”text” name=”Zip” value=”07524″></label><br />
<label>Email: <input type=”email” name=”Email” value=”test@example.com”></label><br />
<label>Telephone: <input type=”tel” name=”Telephone” value=”999-555-1234″></label><br /><br />
<label>Amount: <input type=”text” name=”Amt” value=”1.00″></label><br /><br />
<input type=”submit” value=”Submit” /><br />
</form>Can I add the request.php code into a per page text widget? Assuming the following is correct (in C9) would it fly?
example parts
<?php
$raw_xml = ‘<Request_v1 xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<Application>
<ApplicationID>DEMO</ApplicationID>
<LanguageID>EN</LanguageID>
</Application>
<Payments>
<PaymentType>
…etc…</Request_v1>’;
$tokenization_url = ‘https://www.xyz’;
$request = ‘request=’ . urlencode($raw_xml);
// A pretty standard cURL request here
etc.
$tokenized_xml = stripcslashes(curl_exec($ch));
curl_close($ch);
?>September 3, 2015 at 20:38 UTC #24279scrambler
ModeratorI am not 100% I am following what you are trying to do, but if you want to insert php code in a page, post, or text widget content, you either need to have the “plus” plugin and use the PHP shortcode, or you need to use a PHP exec plugin
September 3, 2015 at 20:56 UTC #24280Weaver
KeymasterAll the text widgets in all versions of Weaver are filtered through the shortcode handler, so any PHP shortcode could be used most anywhere.
September 4, 2015 at 02:46 UTC - Views: 1 #24281swmagic999
ParticipantHmmm. I put the php code into a shortcode and put that into a per page widget text box. Here’s how it looks
WP page html has form as above, page saved as make-donation. The form action is “request.php”
PHP code dropped into shortcode, shortcode dropped into a per page widget.
You can see it here:
https://chea-elks.org/make-donation/However, when I click on submit button it says page not found and the url gives me this:
https://chea-elks.org/make-donation/request.php
Why did it do that and where do I go from there?
September 4, 2015 at 04:46 UTC #24282scrambler
Moderator“Hmmm. I put the php code into a shortcode “You need to be more specific. Didi you use weaver Plus shortcode, if so what exact syntax did you use? or did you use a plugin.The first thing to do is test the principle of the shortcode with some simple PHP like getting the date or something.Once you are sure you have got the usage of the shortcode working with some simple PHP, if your more complicated one is not working, you will probably need to seek help on wordpress.orgSeptember 4, 2015 at 05:18 UTC #24283swmagic999
ParticipantCan I simply do an echo or a print? I’m not sure where it will go.
September 4, 2015 at 05:30 UTC #24284scrambler
ModeratorJust do an echo of the date in the content of a test page to make sure you have the right syntax for the php shortcode you are using and see if it works.You have not said if you are using a plugin or Weaver “plus” php shortcode. If using plus, make sure you have activated the shortcode in The +Xtreme plus Shortcode > PHP pageSeptember 4, 2015 at 07:35 UTC #24285Gillian
ModeratorFor Weaver II Pro, go to Appearance > Weaver II Pro Admin > Weaver II Pro (tab) > Enable PHP (checkbox)
September 4, 2015 at 15:06 UTC #24286swmagic999
ParticipantThanks Gilian. Good catch. I tried that but to no avail.
I added a phptest shortcode and tried that; it looks like this
<?php
echo “Hello world!<br>”;
?>Still got page not found.
I guess that php feature doesn’t work?
I’ll try your recommended plugin scrambler.
September 4, 2015 at 16:00 UTC - Views: 3 #24287Weaver
KeymasterLooking at the HTML source output for the page in the link above, you have a fundamental problem with trying to use PHP.
I’m not sure where you tried to insert the php, but there is a block of PHP code showing in the <head> section. It is raw PHP, which should never be emitted in HTML, and will never be executed. You can look at your page’s HTML source to see that code.
I really can make no sense of the code, and don’t know what is supposed to do.
If you are simply trying to follow instructions for some bit of code to build that donation form from some other source, please understand that you really have to know what you are doing to add PHP code to a WP site, especially when it comes to adding forms. Adding a form requires two things: the <form> itself, and a completely separate PHP file that will be executed when some clicks the submit button for the <form>. That is the hard part. That response needs to be able to tie into the whole WP core and load sequence, and behave properly. It is not that easy to do unless you have a very good understanding of both WordPress core, and PHP coding.
Not trying to be too discouraging – if you know how to do this stuff, then adding a custom form is possible. There are also some plugins that let you build custom forms, but as a whole, it is very hard to add forms to a WP site without the proper background knowledge. You can’t just stick php code here and there without understanding the big picture.
The easiest way to collect donations is to use one of the many sites that are set up to do that (for a small comission, of course), or to use PayPal, which is not very hard. You can create a small Donate button, and PayPal provides you with code that will work directly if pasted into a page, post, or even a text widget. The difference in all these is that their site handles all the processing required for the form.
September 4, 2015 at 16:26 UTC #24288scrambler
Moderator“I added a phptest shortcode and tried that; it looks like this
<?php
echo “Hello world!<br>”;
?>”First sorry for confusing xtreme and pro. If you have activated the shortcode like Gillian mentioned, your syntax is wrong.
If you look at the Shortcode > PHP page, the syntax would be
[weaver_php] echo “Hello world!<br>”; [/weaver_php]
As explained in the SHortcode> PHP page, <?php is replaced by [weaver_php] and ?> by [/weaver_php]
September 4, 2015 at 16:32 UTC #24289swmagic999
ParticipantThanks Bruce. CHEA has signed up with Sage Payments to take and manage payments.
I just thought that I could add the php into either a shortcode on a perpage widget (failed) and tried adding it to the Head section (failed).
The form AND the php work fine at Cloud 9 and were developed at Sage. And I need custom forms because of all the additional fields that must be passed and not available at Sage.
I see that there is more to it now. And here I thought Weaver was magic :-). I’m not a php programmer but could hire one if that is what is required.
Can you give me any ideas of how to integrate the forms and the php with Weaver II Pro? What direction to go now?
Thanks.
September 4, 2015 at 16:34 UTC - Views: 1 #24290swmagic999
ParticipantThere is a plugin for Gravity Forms to integrate it with SagePay, but they are the UK counterparts for Sage Payments USA.
A plugin would work perfectly. Know anyone who writes them?
September 4, 2015 at 16:44 UTC #24291Weaver
KeymasterSo – any plugins you can get for WordPress must be licensed using GPL.
This means that it would likely be pretty easy to modify the UK version plugin to work with the USA version instead.
I would contact the author of the existing UK version and ask if it already works with the USA version, or what it might take to get theme to modify it to work with the USA gateway.
But I suspect you are almost there with the discovery of the existing plugin.
September 5, 2015 at 04:25 UTC - Views: 2 #24292Gillian
Moderator@swmagic999 – just checking that you saw scrambler’s latest reply, because you may have cross-posted.
September 8, 2015 at 23:51 UTC - Views: 3 #24293swmagic999
ParticipantNo Gillian, I had not seen this.
So, I dropped my php code called request.php from the top into this shortcode…
and the “hello world” works (appears on the page directly below the form), but the long code still jumps to
https://chea-elks.org/make-donation/request.phpDoes [weaver_php] ignore xml (as that is what it starts with)?
e.g.
$raw_xml = ‘<Request_v1 xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance” xmlns:xsd=”http://www.w3.org/2001/XMLSchema”>
<Application>
<ApplicationID>DEMO</ApplicationID>
<LanguageID>EN</LanguageID>
</Application>
<Payments>
<PaymentType>
<Merchant>I will need this for security purposes with Sage to avoid php hacks.
Thanks Gillian.
But I am still no closer.
And Bruce, the code is NOT GPL, so I am contacting the 3 manufacturers of Gravity forms interfaces.
-
AuthorPosts
- The forum ‘ Weaver II Pro’ is closed to new topics and replies.