Hey guys. I have recently been asked to connect a flash form to an existing mysql database via php. It's only for a mailing list and needs only to catch the email address. I can handle the validation of the email in flash no problems, I just have no idea where to start with the flash file with regards to the sending the email address to the php and on to the database.
The php file that I have is what i was sent and was used with current html form embedded into the contact html page. I don't know an awful lot about php and flash together and I don't really want to change too much. Any help would be hugely appreciated.
Kind Regards
Rhys Owen
Here is the main PHP code.
PHP Code:
<?
require_once("dbConstants.php");
function storeAddress() {
$message = " ";
// Check for an email address in the query string
if( !isset($_GET['address']) ){
// No email address provided
}
else {
// Get email address from the query string
$address = $_GET['address'];
// Validate Address
if(!preg_match("/^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*$/i", $address)) {
$message = "<strong>Error</strong>: An invalid email address was provided.";
}
else {
// Connect to database
$con = mysql_connect(DBHOST ,DBUSER, DBPASS);
mysql_select_db(DBNAME, $con);
// Insert email address into mailinglist table
$result = mysql_query("INSERT INTO mailinglist SET email='" . $address . "'");
if(mysql_error()){
$message = "<strong>Error</strong>: There was an error storing your email address.";
}
else {
$message = "Thanks for signing up!";
}
}
}
return $message;
}
?>
Here is the dbConstants php.
PHP Code:
<?php
define("DBHOST", "localhost");
define("DBNAME", "web55-mailingl");
define("DBUSER", "web55-mailingl");
define("DBPASS", "jsaf89Hj390fsdg");
?>
your own simple webservice