Skip to main content
Inspiring
Jul 21, 2009 1:56 AM UTC
Question

insert record question

Hy guys.

I have this basic contact page with a form...

http://www.willpower.net.au/contact2.php

I usually have the form action area set to look up this page ..

http://www.willpower.net.au/Contactform.php

which works fine and the php script send the form contents to my chosen email address.

but now I want to add a "insert record" behaviour to the form.

This results in the Actions area of the form in the properties inspector being set to...

<?php echo $editFormAction; ?>

So now It no longer looks up http://www.willpower.net.au/Contactform.php.

Also here is a txt version of the page with the form in it.

http://www.willpower.net.au/contact2.txt

How can I have both functions working?

Can anyone explain?

Thanks in advance.

Will.

This topic is closed to new replies. Start a new post to keep the conversation going.

12 replies

ducati1Author
Inspiring
Jul 25, 2009 1:49 AM UTC

Very helpfull forum and forum member.

Thanks

Translate
David_Powers
Inspiring
Jul 21, 2009 10:30 AM UTC

Moved to the Dreamweaver Application Development forum, which deals with PHP and other server-side issues.

Instead of putting your email processing script in a different page, put it in the same page as the form, and use a conditional statement to make sure that it runs only when the form has been submitted.

The simplest way to do it is to use an include for the mail processing script here:

if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {

  // Add the mail processing script here
  require_once('path/to/mail_processing_script');
  // Then process the insert record server behavior

  $insertSQL = sprintf("INSERT INTO newslettertable (First_Name, email) VALUES (%s, %s)",
                       GetSQLValueString($_POST['First_name'], "text"),
                       GetSQLValueString($_POST['email'], "text"));

If you want to display an acknowledgement, use the option to redirect the user to another page after performing the insert record server behavior.

Note: adding the mail processing script at this point will probably prevent Dreamweaver from recognizing the insert record server behavior, so implement the redirect before adding the include.

Translate
ducati1Author
Inspiring
Jul 21, 2009 9:28 PM UTC

Thanks for replying to my thread I really appreciate it.

I did what you asked but the page doesnt preview correctly in a browser.

Can you please have a look at this page...

http://www.willpower.net.au/contact2.php

Here it is in txt format...

http://www.willpower.net.au/contact2.txt

Thanks so much.

Will

Translate
David_Powers
Inspiring
Jul 22, 2009 11:00 AM UTC

That's a parse error, which means that you're missing a closing curly brace. I suspect that the missing brace should go immediately before the DOCTYPE declaration.

I also notice that you have put this literally in your script (on line 109):

  require_once('path/to/mail_processing_script');

Read my original post and this line of code again. I suggested that the easy way of doing it would be to use an include file for the mail-processing script. Putting everything in the same file, as you have done, is fine; but this line of code is going to cause another error. 'path/to/mail_processing_script' means "replace me with the correct path to the script". Since there is no external script, you don't need this line at all.

Translate