PHP/MySQL: Get value from one field, subtract 2, multiply by 20,   and insert value into another column on form submit

Hello all,
I'm pulling my hair out--thank you for any help you can give
me.
I have a form that a person fills out that has a field that
asks "How
many visitors including you" and I'd like them to type in a
number, and
on submit of the form, have that value -2 multiplied by 20
and inserted
into a "total cost" column.
I'm using the standard DW server behaviors and I've searched
the
internet. How do I perform basic math on that value and
insert it into
the database?
If you have any pointers, that would be great.
Thank you!
-John

John R. Lenz wrote:
> Your code below works great, and I just noticed links to
your book were
> available on your web site, and it's in the mail to me.
Looking forward
> to it.
Thanks, hope you find it useful.
> After the form is posted, I'd like to address the person
who posted it
> by their first name and last name, as well as some of
the details. How
> would you go about doing this in the best way? Would you
set a variable
> and echo it on the 'Thank you' page, or are there better
ways of doing
> it with a recordset and filtering it on form submit?
To pass the details to a thank you page, you would need to
store the
information in $_SESSION variables. You could amend the
earlier script
like this:
<?php
session_start();
if (isset($_POST['visitors'])) {
if ($_POST['visitors'] < 3) {
$num = 0;
} else {
$num = $_POST['visitors'] - 2;
$_POST['total_cost'] = $num * 20;
$_SESSION['total_cost'] = $_POST['total_cost'];
$_SESSION['first_name'] = $_POST['first_name'];
$_SESSION['last_name'] = $_POST['last_name'];
?>
In the thank you page, put the following at the top of the
page:
<?php session_start(); ?>
It must go before anything is output to the browser, so put
it above the
DOCTYPE declaration, and make sure there's no space before
it.
You can then use the $_SESSION variables in the thank you
page.
At the end of the page, add this to clear up the session
variables:
<?php
$_SESSION = array();
destroy_session();
?>
David Powers, Adobe Community Expert
Author, "The Essential Guide to Dreamweaver CS3" (friends of
ED)
Author, "PHP Solutions" (friends of ED)
http://foundationphp.com/

Similar Messages

  • Select records from one database and insert it into another database

    Hi
    I need to write a statement to select records from one database which is on machine 1 and insert these records on a table in another database which is on machine 2. Following is what I did:
    1. I created the following script on machine 2
    sqlplus remedy_intf/test@sptd @load_hrdata.sql
    2. I created the following sql statements in file called load_hrdata.sql:
    rem This script will perform the following steps
    rem 1. Delete previous HR data/table to start w/ clean import tables
    rem 2. Create database link to HR database, and
    rem 3. Create User Data import table taking info from HR
    rem 4. Drop HRP link before exiting
    SET COPYCOMMIT 100
    delete from remedy.remedy_feed;
    commit;
    COPY FROM nav/donnelley@hrp -
    INSERT INTO remedy.remedy_feed -
    (EMPLID, FIRST_NAME, MI, LAST_NAME, BUSINESS_TITLE, WORK_PHONE, -
    RRD_INTRNT_EMAIL, LOCATION, RRD_OFFICE_MAIL, RRD_BUS_UNIT_DESCR) -
    USING SELECT EMPLID, FIRST_NAME, MI, LAST_NAME, BUSINESS_TITLE, WORK_PHONE, -
    RRD_INTRNT_EMAIL, LOCATION, RRD_OFFICE_MAIL, RRD_BUS_UNIT_DESCR -
    FROM ps_rrd_intf_medium -
    where empl_status IN ('A', 'L', 'P', 'S', 'X')
    COMMIT;
    EXIT;
    However, whenever I run the statement I keep getting the following error:
    SP2-0498: missing parenthetical column list or USING keyword
    Do you have any suggestions on how I can fix this or what am I doing wrong?
    Thanks
    Ali

    This doesn't seem to relate to Adobe Reader. Please let us know the product you are using so we may redirect you or refer to the list of forums at http://forums.adobe.com/

  • I want to cut out a head from a photo and insert it into another photo again. In the head hair flying in the wind and the blue sky can be seen between the hairs. This blue sky I want to remove, so I can only use the head with hair flying in another photo.

    I want to cut out a head from a photo and insert it into another photo again. In the head hair flying in the wind and the blue sky can be seen between the hairs. This blue sky I want to remove, so I can only use the head with hair flying in another photo. Is it possible to simply delete this blue color of the sky?

    Make your selection and then use Refine Edge.
    See this video tutorial from Bob Gager.
    https://www.youtube.com/watch?v=xrl3Qwg6zSc

  • How to copy value from one field to another in a Apex Form

    Hello guys,
    There are 2 addresses one is shipping and other is billing. I do not want the customer to re-enter all the details if it is the same address. So based upon an action, it should take the live values from one address field and populate the other address field. I know in JS you can do it, but how to implement that in Apex?
    I guess using Dynamic Actions to achieve this in Version 4 but do not know how. Read quite some info but no luck.
    Thanks in advance!

    Hi,
    I have assumed that you have your shipping address at the top of the page, and then further down the page you have your billing address that you want to enable the users to copy (if this is in reverese, you will need to switch the js variables in the code following).
    I would create a Select List item above the 'Billing Address' details, called PX_SAME_ADDRESSThis select list would be static, with the options Null.
    I also assume you would have pairs of address page items such as:
    PX_SHIPPING_ADDRESS_L1
    PX_BILLING_ADDRESS_L1
    PX_SHIPPING_ADDRESS_L2
    PX_BILLING_ADDRESS_L2
    PX_SHIPPING_POST_CODE
    PX_BILLING_POST_CODEThen copy the following code into the HTML Header of the page definition:
    <script language="JavaScript" type="text/javascript">
    function copyAddress()
       if( $x('PX_SAME_ADDRESS').value == 'YES')
         $x('PX_BILLING_ADDRESS_L1').value = $x('PX_SHIPPING_ADDRESS_L1').value;
         $x('PX_BILLING_ADDRESS_L2').value = $x('PX_SHIPPING_ADDRESS_L2').value;
         $x('PX_BILLING_POST_CODE').value = $x('PX_SHIPPING_POST_CODE').value;
       else //Clear Address Fields
         $x('PX_BILLING_ADDRESS_L1').value = " ";
         $x('PX_BILLING_ADDRESS_L2').value = " ";
         $x('PX_BILLING_POST_CODE').value = " ";
    </script>Then, in your PX_SAME_ADDRESS item, copy the code below into the Element > HTML Form Element Attributes field.
    onChange="copyAddress();"Hopefully this works for you too, and should give you some basis to play around with.
    Amanda.

  • Copy value from one field in subform, to another field in a different subform

    Hi all.  I have been back and forth with enterprise support, and they are telling me what I want to do is impossible.  I find that hard to agree with, so hoping I can get some help here.  I have a document that I am creating, based off an XML.  The page consists of a header subform, a flowing table of variable name, and then a footer.  My problem comes in, that when the table flows to mutliple pages, my header subform will not repeat, even though I have it set as the overflow header.  According to Enterprise Support, this is by design.  The header will repeat on the footer page, if that is on a separate page, just not when the table flows to another page.  So, I came up with a solution to create an additional Header in my table, merge all the cells into one column, and copy my subform into that new header.  I would set that header to appear only on subsequent pages.  So, when I preview my document, it shows the static text fine, as I would expect, however the text fields are blank.  I need a way of copying the values from the original header subform, into the newly created table header subform.  The values will be different based on teh XML input, meaning that the first 3 pages will have one set of values, and the next 3 another, etc..  See sample below...
    <NameValueList>
         <NameValue>
              <NameValueName>Name1<NameValueName>
              <NameValueDesc>Desc1<NameValueDesc>
               <TableValueList>
                   <TableValue>
                        Blah
                   </TableValue>
                   <TableValue>
                        Blah 2
                   </TableValue>
              </TableValueList>
         </NameValue>
         <NameValue>
              <NameValueName>Name2</NameValueName>
              <NameValueDesc>Desc2<NameValueDesc>
              <TableValueList>
                   <TableValue>
                        Blah 5
                   </TableValue>
                   <TableValue>
                        Blah 6
                   </TableValue>
              </TableValueList>
         </NameValue>
    </NameValueList>
    So, if I bind my original header to NameValueName, it will show on the first page which has my header, and the third page that has my footer.  But my 2nd page, that has the table flowed to it, has a blank value.  I tried to put code in the Initialize event of both text boxes, to copy from MainHeader.NameValueName to TableHeader.NameValueName, but that didn't work properly. 
    Any ideas on how to do this?

    Thank you very much for the reply.  I tried putting the copy statement in both the MainHeader and TableHeader initialize events.  There was different behavior, depending on the place I put the copy statement, however neither was correct.  If I put it in the initialize of the TableHeader, the NameValueName that appears on other page is Name1.  Even though the header shows Name2 when it hits the next nodes.  If I put it in the initialize of MainHeader, nothing is copied on the proper table header pages.
    I initially had Master pages, however that really didn't work.  The master pages traversed the NameValueName nodes on it's own loop.  So, Each page displayed the next value in it's own loop, when the main subform loop is still showing data from the previous value.  I know this might be hard to understand, but I'm doing my best to explain.  THanks again for your reply, and I hope that there is another idea out there to fix this...

  • I am sending an email from one account on iphone 4s but the replies are coming into another account on my phone

    I have had an iphone 4s for about a year and have 4 email accounts that come in on it: verizon, gmail, my work, and icloud.  Periodically, I send an email from one account, it shows the message as sent from that account in my sent mail, but the recipient receives it from the gmail account and therefore replies to the gmail.  Has anyone had this happen?  It is almost as if my messages are bouncing into gmail when I send them, although on my phone it shows as having been sent from another account.  I have not had this happen on my computer where I have all of these emails coming in as well.  I thought perhaps it was me not being careful about which account I was sending from when using my phone, but the mail I sent this morning I was very careful to make sure was from verizon, the sent mail on my phone shows it was sent from verizon, and the reply came in on gmail.  Gmail isn't even the default email address- verizon is! My iphone is using version 6.1.3. Does anyone have any ideas? This is a major problem for me so I appreciate any ideas!  Thank you!!!

    I am not sure whether this is related, but I had a problem with Gmail where each time I sent and email via my iPhone it would bounce back in my Gmail account as unread. You migh want to check this Google article explaining why this happens and how to avoid it:
    https://support.google.com/mail/answer/1710338?ctx=gmail&hl=en-GB&authuser=0

  • Copy a metadata value from one field to another

    Hi
    I'm trying to write a rule to copy the value of custom metadata field xdocument and to ddoctile field.
    Can anyone point in the right direction. I'm created a rule with rule activation checking selected and checkin new then use the derived value and this does not work
    Thank you
    Cj

    You should be able to trace what's being sent from the screen, and what command is to be performed by the database.
    Turn on system tracing ( http://docs.oracle.com/cd/E21764_01/doc.1111/e10792/c02_processes.htm#CSMSP535 ) for requestaudit and systemdatabase
    If you confirm that the value for dDocTitle is indeed blank, check your script again (there can be a typo, or anything). I'd go with Boris's other recommendation and add a constant suffix, so that you can get rid of the constraint violation error and then fine tune everything else.
    P.S. actually, it's not a constraint violation, but a feature - see here http://ora-01400.ora-code.com/
    Edited by: jiri.machotka on Feb 3, 2012 3:04 PM

  • How we can get the values  from one screen to another screen?

    hi guru's.
         how we can get the values  from one screen to another screen?
              we get values where cusor is placed but in my requirement i want to get to field values from one screen to another screen.
    regards.
      satheesh.

    Just think of dynpros as windows into the global memory of your program... so if you want the value of a field on dynpro 1234 to appear on dynpro 2345, then just pop the value into a global variable (i.e. one defined in your top include), and you will be able to see it in your second dynpro (assuming you make the field formats etc the same on both screens!).

  • Transfer field value from one screen to another screen

    hi gurus,
    I am using field exit in mm02, i want to transfer field value from one screen to another screen. I am using Export, Import, Some FM like DYNP.......
    but not getting the value.
    can any one give idea about this.
    Thanks in Advance,
    Sudheer.

    I THINK IN FIELD EXITS SOME RESTRICTION IS THERE YOU CAN NOT USE CALL TRANSACTION OR CALL SCREEN. I DONT KNOW WHAT IS YOUR ACTUAL REQUIREMENT. BUT YOU ARE TRYING TO CALL TRANSACTION USING MEMORY ID OR SOMETHING THEN I THINK IN FIELD EXIT YOU CAN NOT DO THAT. PLS CORRECT ME IF I AM WRONG
    REGARDS
    SHIBA DUTTA

  • How to get value from one context node to otehr contect conde in diff views

    Hello Guru's
    We have a rek which is of getting the value from one context node to other context node,
    for example there is Total value in BT111H_OPPT/ITEMLIST (One context node) we need to have the same Total value in the in BT111H_OPPT/DETAILS (other context node) automatically
    Inputs are highly appricated.......

    Hello,
    Thanks for your Reply
    But my rek is i want to get value from different views
    eg BT111H_oppt/itemslist(contex node - BTADMINI) field net value to BT111h_opp/Details(Context node - BTopporth)
    for this which method should i use to chive this.
    Thanks..

  • From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    From two given tables, how do you fetch the values from two columns using values from one column(get values from col.A if col.A is not null and get values from col.B if col.A is null)?

    Hi,
    Use NVL or COALESCE:
    NVL (col_a, col_b)
    Returns col_a if col_a is not NULL; otherwise, it returns col_b.
    Col_a and col_b must have similar (if not identical) datatypes; for example, if col_a is a DATE, then col_b can be another DATE or it can be a TIMESTAMP, but it can't be a VARCHAR2.
    For more about NVL and COALESCE, see the SQL Language manual: http://docs.oracle.com/cd/E11882_01/server.112/e26088/functions119.htm#sthref1310
    I hope this answers your question.
    If not, post a little sample data (CREATE TABLE and INSERT statements, relevant columns only) for all tables involved, and also post the results you want from that data.
    Explain, using specific examples, how you get those results from that data.
    Always say which version of Oracle you're using (e.g., 11.2.0.2.0).
    See the forum FAQ: https://forums.oracle.com/message/9362002

  • How to get a value from one item into another

    How can i get value from one item into another item.
    Ex: I have a report, in there i have check boxes, and when i have checked some rows, and press submitt, a prosses computates it into a item on another page, and a branche redirects to page 3. Then i'm going to use the value in the item into a PL/SQL script in an report to show the submittet items.
    How can i do this?
    Computation script, pages and all that is fixed. But i dont know which PL/SQL statement to use to get th value from the item.

    Hi Fredr1k,
    Use the V() function from pl/sql.
    e.g. V('P3_MY_ITEM')
    will return the value of that page item.
    As long as the pl/sql is called from within the Apex environment.
    Regards
    Michael

  • Exporting and importing a field value from one screen to another in BSP

    Hi All,
    I am working on a BSP application which consists of multiple screens. I have to export the value corresponding to a value selected from a drop down and import it in another screen so that in the next screen values can be populated corrsponding to the value selected in the drop down in the first screen.
    I tried using SET/GET parameter and also EXPORT/IMPORT so that I can get value from one screen into another screen but both the statements are not working in BSP....
    Please help...
    Vivek Gupta
    Edited by: guptav_infy on Feb 21, 2010 11:33 AM

    Hi All,
    This question is still un answered. please reply ..
    Vivek

  • Php - get name from 'file field' and pass to database?

    Is it possible to extract the 'image' name from the 'file' field and insert it into a database using php?
    <input type="file" name="ImageName" id="ImageName">
    I can't have:
    $ImageName = trim($_FILE['ImageName']);
    So hows this handled?
    Cheers
    Os

    Murray *ACP* wrote:
    Should be pretty strightforward, Os.  You know where to ask the questions!
    Yeah.. but I keep coming up against brick walls
    I'm trying to manipulate David Powers PHP Solutions chapter 6 - Uploading Files.
    He's got some sort of complicated function going on which makes sure no two images which are uploaded to a folder have the same name. i.e., london.jpg becomes london_1.jpg. (the php even inserts underscores if there are gaps in the image name)
    If I just use $ImageName = $_FILES["ImageName"]["name"]; potentially I could end up with dozens of images with the same name in the database, which is NOT desirable.
    Of course I could simplyfy everything and use two forms - 1 for uploading the images to the upload folder and then one for inserting the images details into the database BUT that has the drawback of the client needing to type in the name of the image identically to match the name which has been generated in the upload folder and that aint gonna happen in a million years

  • How to find out the max/min value of one field corresponding to a second field in HANA through graphical way.

    Hi,
    I am trying to find out the latest delivery date(EINDT)  for each purchasing document (EBELN) through graphical way.
    The view contains other fields apart from the above mentioned two fields.
    When only the two fields (EBELN, EINDT) are there, then in semantics, I can select 'Max' as aggregation to get the maximum value for each document.
    If I do like this, then I need to join more than 3 views and also so many joins in calculation view. Taking so much time for data preview.
    Hence , please help me in getting the solution while the view contains other fields also.
    Thanks in advance.
    Thanks,
    Jyothirmayi

    Hi Sreehari/Vinoth,
    Thank you for your replies.
    if only two fields are then I can get the max/min values of one field corresponding to other field.
    But more than two fields are there with different values, then let me know how to find out the max/min value of a particular filed corresponding to the 2nd field with other fields also should be in the output.
    I hope you understood my issue.Please revert in case of questions.
    Thanks & Regards,
    Jyothirmayi

Maybe you are looking for