Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
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
Copy link to clipboard
Copied
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.
Copy link to clipboard
Copied
Thanks for replying.
Can you tell me what is a "Curly Brace" ?
You can tell I am not good at coding ![]()
Copy link to clipboard
Copied
A curly brace is a brace that's curly. ![]()
Here are a couple of big ones for you. I've made them big so you can see the curl.
{ }
You can tell I am not good at coding
If you're deploying pages with more than 100 lines of PHP code, you really need to learn the basics. It will save you a lot of time and heartache in the long run.
Copy link to clipboard
Copied
Well I have made the changes but still no success.
Would you mind haveing another look please?
Copy link to clipboard
Copied
I have no idea what changes you have made, and the text version that you posted earlier hasn't been changed.
However, taking another look at it, I notice that you have this at the very beginning of your script:
<?php require_once('Connections/willpower1_newsletter.php'); ?>
if ((isset($_POST["MM_insert"])) && ($_POST["MM_insert"] == "form1")) {
<?php
Look at it closely. The second line is not in PHP tags, so the PHP engine treats it as plain text or HTML. You need to remove the closing PHP tag at the end of line one, plus the opening one at the beginning of line 4.
Copy link to clipboard
Copied
Hi again.
Thanks for your help.
I made those changes but still no success.
Here is the file in txt form
http://www.willpower.net.au/contact2.txt
Copy link to clipboard
Copied
You weren't joking when you said you weren't very good at coding, were you. ![]()
Even when I showed you what curly braces are, you not only used the wrong one, but put it outside the PHP code block. Curly braces always go in pairs. An opening one { marks the beginning of a block of code. A closing one } marks the end of the block. Blocks of code can be nested inside each other, so you might have several opening braces coming in succession, but they must always be matched by closing ones at the end. What was missing was a closing curly brace inside the PHP block just before the DOCTYPE declaration.
There's no shame in being a beginner, but you have 150 lines of script and seem to have very little understanding of what it's doing. Because it doesn't work, you're able to ask for help. The danger is that you'll get something that works, but actually has huge security gaps. By the time you discover the problem, the damage will have been done. I strongly urge you to improve your knowledge of PHP as soon as possible. I'm sorry if this sounds negative, but it's for your own safety and peace of mind.
The other problem with your code was that you were inserting the information into the database before performing all the security checks. I have moved the insert record server behavior code inside the conditional statement that runs only if the mail has been sent. You also had a repeated version of the SQL code in there. It was doing nothing, so I have removed it.
I have amended your file and added a couple of comments in the code indicating some of the changes. I have attached it here, and hope it won't be caught in the virus checking queue for too long.
Copy link to clipboard
Copied
Thanks so much for all your help.
The reason I am no good at coding is because I use all of dreamweavers tools.
I always use the property inspector window and the built in commands to isert records and make php scripts etc.
But I am slowly learning coding.
This excercise has taught me a lot and I am most gratefull.
Regards.
Will.
Copy link to clipboard
Copied
The reason I am no good at coding is because I use all of dreamweavers tools.
I always use the property inspector window and the built in commands to isert records and make php scripts etc.
It's a mistake that a lot of people make. Dreamweaver is a tool that helps you with coding. It's not a substitute for knowledge.
But I am slowly learning coding.
This excercise has taught me a lot and I am most gratefull.
That's good to know. It takes a lot of effort to learn, but you'll find it repays you in the end.
I'm glad to have been of help. Thanks for your kind remarks.
Copy link to clipboard
Copied
Very helpfull forum and forum member.
Thanks
Find more inspiration, events, and resources on the new Adobe Community
Explore Now