Ultrashock Forums > Flash > ActionScript
AS2 - Flash to PHP Help

You are currently viewing our website as a guest which gives you limited access to forums, files and other resources.

Click here to join now for free, and start interacting with our members, download files and much more!

Click here if you are looking for our Flash files and other professional assets.
 
Post Reply | View first unread | Rate Thread Search this Thread | Thread Tools | Display Modes

#1
Bookmark and Share!
AS2 - Flash to PHP Help
Old 2008-07-21

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 "&nbsp;";
  
// 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 ,DBUSERDBPASS);
      
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");
?>
postbit arrow 3 comments | 309 views postbit arrow Reply: with Quote   
Registered User
Starving_Artist is offline
seperator
Posts: 7
2008-07-21
Starving_Artist lives in United Kingdom
seperator

Ultrashock Member Comments:
Silver_S's Avatar Silver_S Silver_S is offline Silver_S lives in Argentina 2008-07-21 #2 Old  
if you are using AS2 you could use the codemonkey web service.
your own simple webservice
Reply With Quote  
feras_flash feras_flash is offline feras_flash lives in Syrian Arab Republic 2008-07-23 #3 Old  
I think loadVariables() is useful in this case

Code:
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
Reply With Quote  
Silver_S's Avatar Silver_S Silver_S is offline Silver_S lives in Argentina 2008-07-23 #4 Old  
Last edited by Silver_S : 2008-07-23 at 10:26.
that's right, but with the codemonkey webservice you could handle errors.
I'ts a lil bit complicated at the begining, but when you catch it, it's really good.
Reply With Quote  
Thread Tools
Display Modes Rate This Thread
Rate This Thread: