Search

I wanted to create a page where I can display the summary of a contact form.

I have created a url parameter to redirect to, and I have also created a DS which holds the last set of data created by the form, but I am working on the possibility that 2 people may well fill in the form at almost the same time, therefore they may get different summaries, which is not secure enough.

Is there a way of doing it? Or am I wide of the mark with the security issue?

How about just keeping them on the same page and using the $_POST values they’ve submitted? The event should return those in your XML. You can test for them, and if they exist display the summary. Otherwise, display the form.

My xml is showing this for events:

<events />

Make sure you disable the redirect, so you post back to the same page.

Ok done that, this is my xml

The form works, emails get sent etc…and the fields are being populated if I have an error and miss a required field.

It doesn’t look like your events XML is working yet. You don’t need to use the special datasource to retrieve the last post at all, only the Events XML. Seeing that events XML can be a little tricky sometimes. There are two methods:

  1. You can force it to show in the HTML on the bottom of your page as a comment. Do this by changing the config file under #####PUBLIC##### change display_event_xml_in_source to yes. You may want to change this back to no later.
  2. You can temporarily change the redirect of your form to http://yoursite.com/the-current-page/?debug and then you’ll be able to see the events XML filled out. Once you know the format, then you can get rid of the ?debug in the redirect.

Ok, but shouldn’t it be working without resorting to these methods?

It will work. You won’t need these debugging methods anymore once you are a Ninja.

10 Debugs = 1 Lesson. 1000 Lessons = 1 Ninja.

:-)

Well of course I do need to assemble my thoughts in preparation for final descent into Ninja’sms - but in the meantime, something is not quite right.

I have my section created, I have my event created - it filters by Send Email, and my form is as such:

<xsl:template name="get-quote">
    <form action="" method="post" id="quoteForm" enctype="multipart/form-data">
    <input name="MAX_FILE_SIZE" type="hidden" value="5242880" />
    <xsl:for-each select="events/get-quote">
          <p class="{@result}">
            <xsl:choose>
              <xsl:when test="@result = 'success'">Email sent.</xsl:when>
              <xsl:otherwise>Please check if all the required fields have been filled.</xsl:otherwise>
            </xsl:choose>
          </p>
        </xsl:for-each>
    <fieldset>
    <label class="required"><span>Contact Name</span><input type="text" name="fields[contact-name]" value="{events/get-quote/post-values/contact-name}" />
    <small class="required">Required</small></label>
    <label class="required"><span>Email Address</span><input type="text" name="fields[email-address]" value="{events/get-quote/post-values/email-address}" />
    <small class="required">Required</small></label>
    <label><span>Contact Number</span><input type="text" name="fields[contact-number]" value="{events/get-quote/post-values/contact-number}" /></label>
    <label><span>Service Required</span>
        <select name="fields[service-required]">
          <option value="Social Media Marketing">Social Media Marketing</option>
          <option value="Search Engine Optimisation">Search Engine Optimisation</option>
          <option value="eMarketing">eMarketing</option>
          <option value="eCommerce">eCommerce</option>
          <option value="Domain Management &amp; Hosting">Domain Management &amp; Hosting</option>
          <option value="Copywriting">Copywriting</option>
          <option value="Content Management Systems">Content Management Systems</option>
          <option value="Brand Development">Brand Development</option>
        </select>
      </label>
     <label><span>Budget</span>
         <select name="fields[budget]">
           <option value="£500">£500</option>
           <option value="£1000">£1000</option>
           <option value="£2500">£2500</option>
           <option value="£10000">£10,000</option>
         </select>
       </label>
       <label><span>Timeline</span>
           <input name="fields[timeline]" type="text" />
         </label>

    <button type="submit" name="action[get-quote]" value="Submit" class="quoteBtn">Get a Quote</button>
    </fieldset>
    <input name="send-email[recipient]" value="{website-owner/author/username}" type="hidden" />
          <input name="send-email[sender-email]" value="fields[email-address]" type="hidden" />
          <input name="send-email[sender-name]" value="fields[contact-name]" type="hidden" />
          <input name="send-email[subject]" value="Quote Request" type="hidden" />
          <input name="send-email[body]" value="fields[contact-name],fields[contact-number],fields[email-address],fields[service-required],fields[budget],fields[timeline]" type="hidden" />
    </form>

</xsl:template>

I am calling that template from a utility into my template:

<xsl:template match="data">

<div id="banner" class="grid_12">
    <h1>
    Get a Quote<span>We specialise in <a href="{$root}/projects-services/ecommerce">eCommerce Design &amp; Development</a>, as well as <a href="{$root}/projects-services/search-engine-optimisation">Search Engine Optimisation</a>, <a href="{$root}/projects-services/social-media-marketing">Social Media Marketing</a>, and <a href="{$root}/projects-services/content-management-systems">Content Management Systems</a>.</span>
    </h1>
</div>

<div id="content" class="grid_12">
    <div id="general-page" class="grid_8 alpha">
        <p class="summary">Some summary here...</p>
        <xsl:call-template name="get-quote" />
    </div>
</div>


</xsl:template>

Now to me that all looks fine, it send the email, it shows up an error if I have missed a field. It’s just not adding the event into the XML.

Have you double-checked that the event is not added (using one of The Jester12’s methods)? The thing is: You can not see the event data if you simply load the debug page. You will need to use one of those debugging methods.

oh I see what your saying, so it could be loading - it’s just not saying it is. I’ll have a look now.

Ok, well my source says this:

<!-- 
<events />
 -->

So it’s definitely not loading it in.

The 2nd method however is working.

Is this by design or a bug?

With the first method, you have to make sure to examine the source code right after sending the form, i.e. without any additional reload of the page. Then it will work as well.

So now, as you know the structure of your event XML, you can follow Craig’s suggestion:

… using the $_POST values they’ve submitted? The event should return those in your XML. You can test for them, and if they exist display the summary. Otherwise, display the form.

Yeah I managed it in the end, had to test against a value being there and it works fine.

Thanks guys.

Create an account or sign in to comment.

Symphony • Open Source XSLT CMS

Server Requirements

  • PHP 5.3-5.6 or 7.0-7.3
  • PHP's LibXML module, with the XSLT extension enabled (--with-xsl)
  • MySQL 5.5 or above
  • An Apache or Litespeed webserver
  • Apache's mod_rewrite module or equivalent

Compatible Hosts

Sign in

Login details