PDA

View Full Version : Flash Form not sending to MySQL?



VersusMG
November 22nd, 2005, 12:23 PM
I have a very important form that i have to have finished by the end of this week. I am using components from Flash 8 to create the form and can trace all the fields by their given var but it will not send the variables to the MySQL database?

I have checked the varialbes, but it's still not working?


<?php
// saving script

// connect to the server
mysql_connect( 'localhost', 'xxxxxx', 'xxxxxx' )
or die( "Error! Could not connect to database: " . mysql_error() );

// select the database
mysql_select_db( 'yea_users' )
or die( "Error! Could not select the database: " . mysql_error() );

// get the variables from the URL request string
$ID = $_REQUEST['ID'];
$fullName = $_REQUEST['fullName'];
$companyName = $_REQUEST['companyName'];
$userName = $_REQUEST['userName'];
$password = $_REQUEST['password'];
$email = $_REQUEST['email'];
$address_1 = $_REQUEST['address_1'];
$address_2 = $_REQUEST['address_2'];
$city = $_REQUEST['city'];
$state = $_REQUEST['state_cb'];
$zip = $_REQUEST['zip'];
$phone = $_REQUEST['phone'];
$aboutCompany = $_REQUEST['aboutCompany'];
$college = $_REQUEST['college'];
$graduated = $_REQUEST['graduated'];
$gradDate = $_REQUEST['gradDate'];
$major = $_REQUEST['major'];
$minor = $_REQUEST['minor'];
$start_up = $_REQUEST['start_up_problems'];
$business_plan = $_REQUEST['business_plan'];
$buying_a_business = $_REQUEST['buying_a_business'];
$zoning = $_REQUEST['zoning'];
$selling = $_REQUEST['selling'];
$pricing = $_REQUEST['pricing'];
$marketing = $_REQUEST['marketing'];
$financing = $_REQUEST['financing'];
$patents = $_REQUEST['patents'];
$import_export = $_REQUEST['import_export'];
$website = $_REQUEST['website'];
$legal = $_REQUEST['legal_issues'];
$productDevelopment = $_REQUEST['productDevelopment'];
$accounting = $_REQUEST['accounting'];

// if $id is not defined, we have a new entry, otherwise update the old entry
if( $ID )
{
$query = "UPDATE `yea_Users` SET `fullName`='$fullName', `companyName`='$companyName', `userName`='$userName', `password`='$password', `email`='$email', `address_1`='$address_1', `address_2`='$address_2', `city`='$city', `state`='state', `zip`='$zip', `phone`='$phone', `aboutCompany`='$aboutCompany', `college`='$college', `graduated`='$graduated', `gradDate`='$gradDate', `major`='$major', `minor`='$minor', `start_up_problems`='$start_up', `business_plan`='$business_plan' WHERE `ID`='$ID'";
}
else
{
$query = "INSERT INTO `yea_Users` ( `fullName`,`companyName`, `userName`, `password`, `email`, `address_1`, `address_2`, `city`, `start_cb`, `zip`, `phone`, `aboutCompany`, `college`, `graduated`, `gradDate`, `major`, `minor`, `start_up_problems`, `business_plan`,`buying_a_business`,`zoning`,`sell ing`,`pricing`,`marketing`,`financing`,`patents`,` import_export`,`website`,`legal_issues`,`productDe velopment`,`accounting` )
VALUES ( '$fullName','$companyName','$userName', '$password','$email','$address_1','$address_2','$c ity','$state','$zip','$phone','$aboutCompany','$co llege','$gradutated','$gradDate','$major','$minor' ,'$start_up','$business_plan','$zoning','$selling' ,'$pricing','$marketing','$financing','$patents',' $import_export','$website','$legal','$productDevel opment','$accounting')";
}

// save the info to the database
$results = mysql_query( $query );

?>


and the actionscript


submit_mc.onRelease = function() {
var fullName = fullName_txt.text;
var companyName = companyName_txt.text;
var userName = userName_txt.text;
var passWord = passWord_txt.text;
var cpassWord = cpassWord_txt.text;
var email = email_txt.text;
var address1 = address1_txt.text;
var address2 = address2_txt.text;
var city = city_txt.text;
var state_cb = statelc.getValue();
var zip = zip_txt.text;
var phone = phone_txt.text;
var company = company_txt.text;
var college = college_txt.text;
var gradYes = gradYes.getData();
var gradNo = gradNo.getData();
var graduated = gradYes, gradNo;
var gradDate = gradDate_txt.text;
var major = major_txt.text;
var minor = minor_txt.text;
var start_up_problems = start_up_problems.getFocus();
var business_plan = business_plan.getFocus();
//
//trace(fullName);
//trace(userName);
//trace(passWord);
//trace(cpassWord);
//trace(email);
//trace(address1);
//trace(address2);
//trace(city);
//trace(state_cb);
//trace(zip);
//trace(phone);
//trace(company);
//trace(college);
//trace(graduated);
//trace(gradDate);
//trace(major);
//trace(minor);
trace(business_plan.getValue());
//
////////
if (validEmail(vemail) && (!fullName.isInvalid()) && (!userName.isInvalid()) && (!comments.isInvalid())) {
loadVariablesNum("signup.php", 0, "POST");
} else {
if (fullName.isInvalid()) {
fullName = fnameErr;
}
if (userName.isInvalid()) {
lname = lnameErr;
}
if (!validEmail(vemail)) {
vemail = vemailErr;
}
if (comments.isInvalid()) {
comments = commentsErr;
}
action = "";
stop();
}
};

Crucial
November 24th, 2005, 06:47 PM
I posted this response over at DQS (http://forum.24-7media.de/viewtopic.php?t=3912) already but not sure which place you visit most often... so here it is again:


I'm no PHP whiz by any means, but I don't think you need quotes around your table name. So right now you have:

INSERT INTO `yea_Users`

but I think you could just use:

INSERT INTO yea_Users

Have you tried putting an echo statement in your PHP script to make sure that the variables are being passed to the script (much like your trace statements in the Flash file)? This may help debug whether the problem is in the Flash code or in the PHP script.

What version of PHP are you running? I'm not sure anyone out there is still on anything earlier than PHP 4.1.0, but if you are $_REQUEST was not available in earlier versions. You would have to use $HTTP_POST_VARS instead.

Hope that helps,
-Dave