OK… I am now heading into day 3 of attempting to populate a database through my flash form!! I figure I need some help before I crack!
I just can’t get it to work at all…
I am able to get my variables from flash for the purposes of sending them via email but need a PHP/SQL guru to tell me what I am doing so horribly wrong in this case… it may be something really obvious to someone above my novice level - Please?
Here’s my code:
Actionscript:
function sendDb() {
var dataOut:LoadVars = new LoadVars();
var dataIn:LoadVars = new LoadVars();
dataOut.first_name = first_name.text;//First Name
dataOut.last_name = last_name.text;//Last Name
dataOut.website_url = website_url.text;//Website URL
dataOut.bus_name = bus_name.text;//Business Name
dataOut.contact_number = contact_number.text;//Contact Number
dataOut.website_cat = website_cat.text;//Website Catagory
dataOut.website_caption = website_caption.text;//Website Caption
dataOut.email_address = email_address.text;//Email address
dataOut.continent = continent.text;//Continent
dataOut.enter_coord = enter_coord.text;//X Y Coordinates
dataOut.total_boxes = total_boxes;//Total Boxes
dataOut.box_numbers = box_numbers;//Box Numbers
dataOut.need_website = need_website.selected;//I need a new website!
dataOut.terms = terms.selected;//I have read the terms & conditions
dataOut.sendAndLoad("buyForm_db.php", dataIn, "POST");
gotoAndPlay("Thankyou");
};
btn_submit.onRelease = function() {
sendDb();
};
And my first PHP:
<?php
require("db.php");
/*php varibales to be used*/
$first_name = $_POST['first_name'];
$last_name = $_POST['last_name'];
$website_url = $_POST['website_url'];
$bus_name = $_POST['bus_name'];
$contact_number = $_POST['contact_number'];
$website_cat = $_POST['website_cat'];
$website_caption = $_POST['website_caption'];
$email_address = $_POST['email_address'];
$continent = $_POST['continent'];
$enter_coord = $_POST['enter_coord'];
$total_boxes = $_POST['total_boxes'];
$box_numbers = $_POST['box_numbers'];
$need_website = $_POST['need_website'];
$terms = $_POST['terms'];
/* Strip any escape characters etc */
$first_name = stripslashes($first_name);
$last_name = stripslashes($last_name);
$website_url = stripslashes($website_url);
$bus_name = stripslashes($bus_name);
$contact_number = stripslashes($contact_number);
$website_cat = stripslashes($website_cat);
$website_caption = stripslashes($website_caption);
$email_address = stripslashes($email_address);
$continent = stripslashes($continent);
$enter_coord = stripslashes($enter_coord);
$total_boxes = stripslashes($total_boxes);
$box_numbers = stripslashes($box_numbers);
$need_website = stripslashes($need_website);
$terms = stripslashes($terms);
$q1 = "INSERT INTO Customers (first_name, last_name, website_url, bus_name, contact_number, website_cat, db_password, website_caption, email_address, continent, enter_coord, total_boxes, box_numbers, need_website ,terms) VALUES ('$first_name', '$last_name', '$website_url', '$bus_name', '$contact_number', '$website_cat','$website_caption','$email_address', '$db_password', '$continent', '$enter_coord', '$total_boxes', '$need_website', '$terms')";
mysql_close($connection);
?>
And my initial connection php:
<?
/* Database Information - Required!! */
/* -- Configure the Variables Below --*/
$dbhost = 'localhost';
$dbusername = 'my_username';
$dbpasswd = 'my_password';
$database_name = 'my_database';
/* Database Stuff, do not modify below this line */
$connection = mysql_pconnect("$dbhost","$dbusername","$dbpasswd")
or die ("Couldn't connect to server.");
echo "connection = $connection";
$db = mysql_select_db("$database_name", $connection)
or die("Couldn't select database.");
echo "db = $db";
?>