Solved

Simple flash/php form to create database

Posted on 2011-03-01
8
651 Views
Last Modified: 2013-11-11
I need to create a simple form in flash that a user will fill out and on submit will create a new database and fill it with the form data using php and mqsql. Does anyone have some sample code to this effect?
0
Comment
Question by:brettacvh
  • 3
  • 3
8 Comments
 
LVL 17

Assisted Solution

by:Dushan De Silva
Dushan De Silva earned 500 total points
ID: 35012808
0
 

Author Comment

by:brettacvh
ID: 35012846
To be a bit more detailed I need my flash form to run the following kind of query:

CREATE TABLE  `new`.`users` (
  `test_uid` int(10) unsigned NOT NULL AUTO_INCREMENT,
  `test_email` varchar(100) NOT NULL,
  `test_address` varchar(45) DEFAULT NULL,
  `test_message` varchar(45) DEFAULT NULL,
  `ipaddress` varchar(45) DEFAULT NULL,
  `test_pword` char(20) NOT NULL,
  `test_gname` char(80) NOT NULL,
  `test_lname` char(80) NOT NULL,
  `test_active` char(1) DEFAULT 'y',
  `test_lvl` int(10) unsigned NOT NULL DEFAULT '1',
  `test_rdate` datetime DEFAULT NULL,
  `test_username` varchar(45) NOT NULL,
  `test_permission` varchar(45) NOT NULL DEFAULT '1',
  `test_contactno` varchar(45) DEFAULT NULL,
  PRIMARY KEY (`pogu_uid`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=latin1

Open in new window


but I'm not sure how to structure the php.

For the flash I guess I'll be using something like this:

submit1.onPress = function(){
	myData.test_uid_txt = test_uid_txt.text
		myData.test_email_txt = test_email_txt.text
		myData.test_address_txt = test_address_txt.text
		myData.sendAndLoad("form.php", myData, "POST")
	}
}

Open in new window

 ... etc
0
 

Author Comment

by:brettacvh
ID: 35013239
Apologies. I am incorrect. I don't need to be creating the database but rather updating an existing database with:

insert into users(pogu_username,
pogu_pword, 
pogu_gname, 
pogu_lname, 
pogu_gender, 
pogu_rdate, 
pogu_contactno,
pogu_email,
pogu_dob, 
pogu_address, 
pogu_message,
ipaddress)

Open in new window

0
Master Your Team's Linux and Cloud Stack!

The average business loses $13.5M per year to ineffective training (per 1,000 employees). Keep ahead of the competition and combine in-person quality with online cost and flexibility by training with Linux Academy.

 
LVL 17

Accepted Solution

by:
Dushan De Silva earned 500 total points
ID: 35013267
http://www.kirupa.com/developer/actionscript/flashphpxml_integration.htm

Above SQL statement you should not run from flash in normal practice. You should create database table using phpmyadmin, mysql gui or some other mysql client interface.

Then use php script to insert values to database which captures from the flash form.

BR Dushan.
0
 
LVL 17

Assisted Solution

by:Dushan De Silva
Dushan De Silva earned 500 total points
ID: 35013337
Please find below sample code.
----------------------------------------------flash code ---------------------------------------------
var submitObject:LoadVars = new LoadVars();

submit1.onRelease = function():Void
{

     submitObject.myname = myname.text;
     submitObject.mycontact = mycontact.text;
     submitObject.myabout = myabout.text;
     submitObject.mymessage = mymessage.text;
     submitObject.send("http://WEBSITE.com/contactscript.php", "_self", "POST");
};
-------------------------------------------------------------------------------------------------------


----------------------------------------------php code ------------------------------------------------
<?php
$conn = mysql_connect("local host", "username", "password");
mysql_select_db("blc", $conn);
$myname = $_POST['myname'];
$mycontact = $_POST['mycontact'];
$myabout = $_POST['myabout'];
$mymessage = $_POST['mymessage'];

$query="INSERT INTO contacts values ('', '$myname', '$mycontact', '$myabout', '$mymessage')";
$sql_run = mysql_query($query, $conn) or die(mysql_error());

?>
-------------------------------------------------------------------------------------------------------

Open in new window

0
 

Author Comment

by:brettacvh
ID: 35014038
To add to my question: how do I validate the radio buttons in the flash form? I have 2 radio buttons with a group name of my_vars.gender The code I am trying is

if (my_vars.gender.selection == undefined) 
		{
			error_clip.gotoAndStop(44);
		}

Open in new window



but doesn't work
0

Featured Post

VMware Disaster Recovery and Data Protection

In this expert guide, you’ll learn about the components of a Modern Data Center. You will use cases for the value-added capabilities of Veeam®, including combining backup and replication for VMware disaster recovery and using replication for data center migration.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

FAQ pages provide a simple way for you to supply and for customers to find answers to the most common questions about your company. Here are six reasons why your company website should have a FAQ page
When crafting your “Why Us” page, there are a plethora of pitfalls to avoid. Follow these five tips, and you’ll be well on your way to creating an effective page.
The viewer will learn how to look for a specific file type in a local or remote server directory using PHP.
The goal of the tutorial is to teach the user how to live broadcast using Flash Media Live Encoder and connecting it to YouTube to broadcast. Log into your Youtube account, choose live stream settings, start live stream from Flash Media Live Enc…

820 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question