The Ultrashock Ultra Bundle
  • Home
  • Community
  • Forum
  • Flash
  • ActionScript
  • Thread
  •  
  • Previous topic
  • Next topic
Sign up to post

Flash
 ActionScript

  • Starving_Artist Author 
    • 384 
    • 0 
    • 3 
    Flash to PHP Help
    Silver_S

    Last reply Jul 23 2008, 03:25 PM

    by Silver_S

    Posted: Jul 21 2008, 03:17 PM

    by Starving_Artist

     

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]

  3 REPLIES
 
Silver_S
1  
Silver_S

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
  •  
feras_flash
2  
feras_flash

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 wink

  • 23 July 2008 02:52 PM
  •  
Silver_S
3  
Silver_S

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.

  • 23 July 2008 03:25 PM
  •  
  •   Log in or join for free to make a comment.
 
Topic actions
  •  Share on Facebook
  •  Share on Twitter
Topic Categories
  •  Show All Topics
  •  Development
    •  Server Side
    •  Client Side
  •  Creative Software
    •  Web
    •  Video
    •  3D
    •  Illustrator
    •  Photoshop Battles
    •  Photoshop
  •  Design
    •  Typography
    •  Resources & Insight
    •  Checkpoint
  •  Career
    •  Copyright Matters
    •  Advice & issues
    •  Job Seekers
    •  Job Offers
  •  Flash
    •  UltraMath
    •  OOP
    •  Third Party Tools
    •  Open Source alternatives
    •  Data Communication
    •  Components
    •  Flex
    •  AIR
    •  Flash Lite
    •  Flash Professional
    •  Flash Newbie
    •  ActionScript
    •  XML
  •  Lounge
    •  Polls
    •  Random Chat
    •  Showcase And Critique
    •  BombShock Award Nominations
  •  Community Essentials
    •  BombShock Award Winners
    •  Tutorials
    •  Interviews
    •  News
    •  Bitmap tutorials
Popular Topics
  • Sort by: 
  • Activity
  • Views
  • Comments
  • Likes
Advertise with us
  • Your advertisement here!
  • loading
Ultrashock
  • Creative Assets
  • Community
  • Blog
  1. Home
  2. Forum
+/-
Creative Assets
  • Categories
  • Contributors
  • How to buy
Make Money
  • Commission Rates
  • Referral Program
  • Contributor Program
Community
  • Activity Feed
  • Forum
  • Profiles
About
  • Quick Tour
  • Our History
  • Banners & Logos
Support
  • Contact Ultrashock
  • Advertise with us
  • Legal Information
  •  Keep up to date
  • Flash 779  Flash
  • Audio 6,481  Audio
  • Vector 2,130  Vectors
  • Image 12,338  Images
  • Creative Assets 21,728  Assets
  • Profiles 282,751  Members
  • Topics 93,776  Topics
  • Blog 4  Blog
  • Facebook 1,679  Facebook
  • Twitter 1,163  Twitter
  • Join our FREE monthly newsletter!
  • Archive
  • Invalid email address. Please try again.
Subscribe
  • ©2012 Ultrashock LLC - All rights reserved
  • Terms of Use
  • Privacy Policy
  • Switch to dark theme
  • RSS Feeds
  • Top

©2012 Ultrashock LLC - All rights reserved

Printed on Sat, February 11, 2012 - 20:06:00