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]<?
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 = “Error: 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 = “Error: There was an error storing your email address.”;
}
else {
$message = “Thanks for signing up!”;
}
}
}
return $message;
}
?>[/PHP]
Here is the dbConstants php.
[PHP]<?php
define(“DBHOST”, “localhost”);
define(“DBNAME”, “web55-mailingl”);
define(“DBUSER”, “web55-mailingl”);
define(“DBPASS”, “jsaf89Hj390fsdg”);
?>[/PHP]
if you are using AS2 you could use the codemonkey web service.
http://www.ultrashock.com/forums/sources-and-experiments/your-own-simple-webservice-81898.html
- 21 July 2008 03:34 PM
-
I think loadVariables() is useful in this case
address="email@host.com";
loadVariables("add.php",this,"GET");
this code is sending the ‘address’ from flash to “add.php” as GET param and php doing his job without any display ... you just see flash
you can read more about loadVariables() function in flash HELP
- 23 July 2008 02:52 PM
-
- Log in or join for free to make a comment.


