close ad
Install the LAtest Updates to Work with CC 2017 and CC 2018
open ad
View Menu

Technical Support Forums

Free, outstanding support from WebAssist and your colleagues

rating

Quote form

Thread began 8/14/2014 9:34 am by saf01 | Last modified 8/19/2014 2:53 pm by Jason Byrnes | 2296 views | 18 replies |

saf01

Quote form

Hi,

I made a form with several fields, when submitted, displays what you submitted on the next screen - this is the form's action php page.
This works fine. Now the issue is this:

I want to make the form also submit values entered into a database (the database is created already). When I add MYSQLi insert record behaviour to the form and change the form's action page to itself, then change the insert record gotopage to the actual action php page, the quote values don't appear on the screen, but the form values are entered into the database. If I change the form's action to the actual action php page and then leave blank the insert record gotoPage, then the values are displayed on the action page but no values are added to the database.

If I add the insert record behaviour to the actual action page, it works, but everytime I refresh that page it adds new values to the database.

On the action page, Im using the following code to show values on screen:

<?php

foreach ($_POST as $key => $value) {
$$key = $value;
}

If (empty ($value1)) {
die( 'Error !' );
}
If (empty ($value2)) {
$value2 = "value2";
}
If (empty ($value3)) {
$value3 = "value3";
}
?>

Please can you tell me what's the best way to show values on the screen and insert them into the database.

Thanks

Sign in to reply to this post

Jason ByrnesWebAssist

  If I add the insert record behaviour to the actual action page, it works, but everytime I refresh that page it adds new values to the database.  



change the trigger for the insert record behavior to Any form post.

Sign in to reply to this post

saf01

Thanks, done that. Still inserts a new record on page refresh of the action page. Is adding the insert behaviour on the action page the right place to have it? Adding the insert behaviour on the form page it works if the form page doesn't have any action. But then the screen printing of what is submitted doesn't appear on the action page.

So how do I display the values added from the form page to appear on the action page using MYSQLi behaviour?
If the Form page has a form field: <input name="value1" type="text" id="value1" size="40">
How to display this form field print on the action page?

Please help.

Sign in to reply to this post

Jason ByrnesWebAssist

all form processing must occur on the action page.

you have 2 options:
1) set the action page to be the same page as the form
add the insert on that page.
in the insert behavior, there is an option to save the new record ID to a session variable
set the insert to redirect to another page, and use the session in a recordset to look up the inserted data and display it from the recordset

2) Set the action to go to the other page, add the insert on that page and use the form bindings there.

if the page is refreshed, it will resubmit the form though. this wont happen if you use option 1.

Sign in to reply to this post

saf01

Thanks again. I followed option 1 and its working, I see the values entered and it inserts - I added recordset filtered by session variable to display.
I have another question, how do I do a calculation e.g: recordset_value1 + recordset_value2 and display it. Another example would be a dropdown form field value on the form page:

<?php
If ($Recordset1->getColumnVal("value1") == '500 - 999') {
$myquote = 200;
}
?>

If I run this on the browser, it gives undefined variable myquote. I want to display myquote as 200 if the dropdown selected is '500 - 999'

Please help with this final one.

Sign in to reply to this post

Jason ByrnesWebAssist

add the bindings for the 2 columns to the page, then post the binding code here, and i can show you how to add them together.

Sign in to reply to this post

saf01

ok. Here are my two bindings:

<?php echo($Recordset1->getColumnVal("area")); ?>
<?php echo($Recordset1->getColumnVal("design")); ?>

Area is selected from a dropdown on the form page, then displayed on the action page. Design is also selected from another dropdown on the form page. For example:

If area dropdown is: '500 - 999' then $myquote1 value is 200
If design dropdown is: 'Shop Front' then $myquote2 value is 100

$TotalQuote = $myquote1 + myquote2 <------ I wish to display and do this calculation

Thanks for your help.

Sign in to reply to this post

Jason ByrnesWebAssist

use this:
<?php echo($Recordset1->getColumnVal("area") + $Recordset1->getColumnVal("design")); ?>

Sign in to reply to this post

saf01

Thanks Jason. Thats great, appreciate it.

Sign in to reply to this post

saf01

I wish to add form validation now. Is WebAssist server validation ok to use with mysqli insert record behaviour on the form?

Please advise.

Sign in to reply to this post
loading

Build websites with a little help from your friends

Your friends over here at WebAssist! These Dreamweaver extensions will assist you in building unlimited, custom websites.

Build websites from already-built web applications

These out-of-the-box solutions provide you proven, tested applications that can be up and running now.  Build a store, a gallery, or a web-based email solution.

Want your website pre-built and hosted?

Close Windowclose

Rate your experience or provide feedback on this page

Account or customer service questions?
Please user our contact form.

Need technical support?
Please visit support to ask a question

Content

rating

Layout

rating

Ease of use

rating

security code refresh image

We do not respond to comments submitted from this page directly, but we do read and analyze any feedback and will use it to help make your experience better in the future.

Close Windowclose

We were unable to retrieve the attached file

Close Windowclose

Attach and remove files

add attachmentAdd attachment
Close Windowclose

Enter the URL you would like to link to in your post

Close Windowclose

This is how you use right click RTF editing

Enable right click RTF editing option allows you to add html markup into your tutorial such as images, bulleted lists, files and more...

-- click to close --

Uploading file...