Skip to main content
Participant
March 24, 2009
Question

Forms and Databases.

  • March 24, 2009
  • 1 reply
  • 515 views
Is it possible to send the form information to an email recipient and add to a database at the same time? I am PHP and MySQL.

Thanks,

Bob
This topic has been closed for replies.

1 reply

Inspiring
March 24, 2009
BWSC wrote:
> Is it possible to send the form information to an email recipient and add to a database at the same time? I am PHP and MySQL.

Yes, but Dreamweaver won't do it automatically for you. Use the Insert
Record server behavior to insert the form information into the database.
Then switch to Code view and locate the following line ($connAdmin is
the name of your MySQL connection, so it is likely to be different):

$Result1 = mysql_query($insertSQL, $connAdmin) or die(mysql_error());

Immediately after that line, add a conditional statement like this:

if ($Result1) {
// insert email script here
}

Put your mail processing script inside the conditional statement.

--
David Powers
Adobe Community Expert, Dreamweaver
http://foundationphp.com
BWSCAuthor
Participant
March 25, 2009
Do you mean to put this;

if (($_POST['sender_name'] == "") ||
($_POST['sender_email'] == "") ||
($_POST['message'] == "")) {
header("Location: http://contact.html");
exit;