Home Forums Archived Forums Weaver II Theme Weaver II Pro Can php script go into a perpage text widget?

Viewing 16 posts - 1 through 16 (of 19 total)
  • Author
    Posts
  • #18201
    swmagic999
    Participant

    I 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&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema”&gt;
      <Application>
        <ApplicationID>DEMO</ApplicationID>
        <LanguageID>EN</LanguageID>
      </Application>
      <Payments>
        <PaymentType>
    …etc…

    </Request_v1>’;
       
         $tokenization_url = ‘https://www.xyz&#8217;;
       
        $request = ‘request=’ . urlencode($raw_xml);
       
        // A pretty standard cURL request here
    etc.
       
        $tokenized_xml = stripcslashes(curl_exec($ch));
        curl_close($ch);
       
    ?>

    #24279
    scrambler
    Moderator

    I 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

    #24280
    Weaver
    Keymaster

    All the text widgets in all versions of Weaver are filtered through the shortcode handler, so any PHP shortcode could be used most anywhere.

    #24281
    swmagic999
    Participant

    Hmmm.  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?

    #24282
    scrambler
    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.org
    #24283
    swmagic999
    Participant

    Can I simply do an echo or a print?  I’m not sure where it will go.

    #24284
    scrambler
    Moderator
    Just 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 page
    #24285
    Gillian
    Moderator

    For Weaver II Pro, go to Appearance > Weaver II Pro Admin > Weaver II Pro (tab) > Enable PHP (checkbox)

    #24286
    swmagic999
    Participant

    Thanks 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.

    #24287
    Weaver
    Keymaster

    Looking 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.

    #24288
    scrambler
    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]

    #24289
    swmagic999
    Participant

    Thanks 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.

    #24290
    swmagic999
    Participant

    There 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?

    #24291
    Weaver
    Keymaster

    So – 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.

    #24292
    Gillian
    Moderator

    @swmagic999 – just checking that you saw scrambler’s latest reply, because you may have cross-posted.

    #24293
    swmagic999
    Participant

    No 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.php

    Does  [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&#8221; xmlns:xsd=”http://www.w3.org/2001/XMLSchema”&gt;
      <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.

Viewing 16 posts - 1 through 16 (of 19 total)
  • The forum ‘ Weaver II Pro’ is closed to new topics and replies.