Results 1 to 3 of 3

Thread: PHP coding question in a FORMMAIL TEMPLATE (TEMPLATEURL)

  1. #1
    Join Date
    Dec 2008
    Location
    Davenport, Iowa USA
    Posts
    29

    Default PHP coding question in a FORMMAIL TEMPLATE (TEMPLATEURL)

    I'm using TEMPLATEURL which I believe forces the template thru the PHP processor prior to displaying on the client. Given that, I'm trying to do some simple math (multiply and add) based on the information submitted by the user. However, not being a PHP coder, I'm having trouble getting the math to work. Here's an example of what I'm trying to do:

    <? $total_cost = 0;
    $total_cost += $num_hats * $hat_price;
    $total_cost += $num_visors * $visor_price;
    if($shipping = "Yes")
    {$total_cost += 5;}
    echo $total_cost;
    ?>

    $num_hats, $num_visors and $shipping are fields that are submitted by the user on the form which points to the template. $hat_price and $visor_price are set in an include statement earlier in the template. $total_cost keeps coming up as zero (0) when it should be something positive like 55. Any help would be appreciated. Thanks.

  2. #2
    Join Date
    Dec 2003
    Posts
    3,980

    Default Re: PHP coding question in a FORMMAIL TEMPLATE (TEMPLATEURL)

    Hi,

    Calculations cannot work like that for two reasons:
    1. The template substitutions occur on the output of the template (after any PHP is executed).
    2. The fields submitted from the form are not available inside PHP code in the template.
    There is a way to use $SESSION_ACCESS to make submitted fields available in a PHP session, but there's no guarantee that your server will allow the template to access the session.

    FormMail tries to make this happen, but it's under the control of your hosting provider and the way they've installed PHP.
    Russell Robinson - Author of Tectite FormMail and FormMailDecoder
    http://www.tectite.com/

  3. #3
    Join Date
    Nov 2013
    Posts
    10

    Default Re: PHP coding question in a FORMMAIL TEMPLATE (TEMPLATEURL)

    How can call any javascript function without saying onclick, onchange, onblur etc events in php?

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 0
    Last Post: 01-Dec-2011, 10:59 AM
  2. Question about TEMPLATEURL and security
    By tomdkat in forum Community Support
    Replies: 5
    Last Post: 22-Aug-2009, 09:47 PM
  3. file_names and template question
    By stlmusic in forum FormMail Subscription Support
    Replies: 4
    Last Post: 04-Feb-2009, 10:14 PM
  4. Template question
    By dmac in forum Features Questions
    Replies: 7
    Last Post: 01-Feb-2009, 10:28 PM
  5. mail_options issue, and templateurl template issu
    By squeegee in forum Community Support
    Replies: 2
    Last Post: 19-Dec-2006, 11:05 PM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •