I have created a flash site for me and my fiance’s upcoming wedding. I have created a flash from so that we can collect the addresses of our guests.
Currently the contents of the form are emailed to me. I have created a mySQL DB with id, name, address, and email. I would like to have the contents of the form posted to the DB as well as emailed. I have tried to utilize numerous tutorials to get it to work but I have spent many hours without success. I was hoping that somebody would be willing to take a look at my PHP script and tell me if they can find what my problem might be. The email portion of the script works fine. The only things I have changed in the script are DBhost, DBuser, DBpassword, everything else is exactly as it appears in the script I have been testing. It may be something really simple (hopefully). I would really appreciate the help. My PHP and SQL knowledge are both quite limited.
Please feel free to peruse our site. I would love to have some feedback. Thanks in advance.
<?
//SQL PORTION OF SCRIPT
// Database Connectivity Variables and other Variables
$DBhost = "mySQL.net"; // Database Server
$DBuser = "mylogin"; // Database User
$DBpass = "myPassword"; // Database Pass
$DBName = "febridge"; // Database Name
$table = "guestList"; // Database Table
// Connect to mySQL Server
$DBConn = mysql_connect($DBhost,$DBuser,$DBpass);
// Select mySQL Database
mysql_select_db($DBName, $DBConn);
// Part Two - Choose what action to perform
$action = $_GET['action'];
switch($action) {
case 'write' :
// Recieve Variables From Flash
$name = stripslashes($HTTP_POST_VARS['sender_name']);
$email = stripslashes($HTTP_POST_VARS['sender_mail']);
$comments = stripslashes($HTTP_POST_VARS['sender_message']);
// Insert the data into the mysql table
$sql = 'INSERT INTO ' . $table .
' (`id`,
`name`,
`email`,
`message`
)
VALUES
(\'\','
. '\'' . $name . '\','
. '\'' . $email . '\','
. '\'' . $comments . '\'
)';
$insert = mysql_query($sql, $DBConn);
}
//EMAIL PORTION OF SCRIPT
if(!empty($HTTP_POST_VARS['sender_mail']) || !empty($HTTP_POST_VARS['sender_message']) || !empty($HTTP_POST_VARS['sender_subject']) || !empty($HTTP_POST_VARS['sender_address']) || !empty($HTTP_POST_VARS['sender_name']))
{
$to = "myemailaddress@myurl.com";
$subject = "wedding guest address";
$body = stripslashes($HTTP_POST_VARS['sender_message']);
$body .= "
---------------------------
";
$body .= "Mail sent by: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">
";
$body .= "Our Address is: " . $HTTP_POST_VARS['sender_address'] . "";
$header = "From: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">
";
$header .= "Reply-To: " . $HTTP_POST_VARS['sender_name'] . " <" . $HTTP_POST_VARS['sender_mail'] . ">
";
$header .= "X-Mailer: PHP/" . phpversion() . "
";
$header .= "X-Priority: 1";
if(@mail($to, $subject, $body, $header))
{
echo "output=sent";
} else {
echo "output=error";
}
} else {
echo "output=error";
}
?>