Hi,
I am using the code below to try and send a customers information from a flash form to a database. However, when I check the database no information has been added. I am not very good at php!
Flash code:Code:<?php // Database connection variables $dbDatabase = "Bazaar Ceramics"; //convert the POST variables from flash to local variables $cid = $_POST['cid']; $FName = $_POST['fname']; $LName = $_POST['lname']; $Email = $_POST['email']; $SNum = $_POST['snum']; $SName = $_POST['sname']; $Suburb = $_POST['suburb']; $PCode = $_POST['pcode']; $Country = $_POST['country']; $Phone = $_POST['phone']; $User = $_POST['user']; $Password = $_POST['upassword']; // Make sure the data has been sent to the script from flash if($cid==""||$LName ==""){ echo '&message=you+must+enter+customer+record&'; exit; } //check if you can connect to the mysql db otherwise exit $conn = @mysql_connect("localhost", "admin", ""); if (!$conn) { die("Connection failed: " .mysql_error()); } //connect to database or exit if (!(mysql_select_db($dbDatabase, $conn))){ echo '&message=db+selection+failed&'; exit; } //send mysql a query to select records from the products table where the id's match. If the query fails exit if (!($result = mysql_query("SELECT * FROM customers where customerid= '$cid'"))){ echo '&message=query+failed&'; exit; } //Retrieve the number of rows (records)that have been returned from above query $num_results = mysql_num_rows($result); if($num_results <= 0) {//customer does not exist so insert $query = "INSERT INTO customers (cid, FName, LName, Email, Housenum, Streetname, Suburb, Postcode, Country, Phone, Username, Password) VALUES ('$cid','$FName', '$LName', '$Email', '$SNum', '$SName','$Suburb','$PCode','$Country','$Phone','$User','$Password')"; if (mysql_query($insert, $conn)) echo "&message=the+customer+'$FName'+'$LName'+has+been+successfully+added&"; else echo '&message=the+insert+was+not+successful&'; }else { //customer exists so update existing customer $update = "update products set FName='$FName'; LName='$LName'; where customerid='$cid'"; if(mysql_query($update, $conn)) echo "&message=the+details+have+been+updated&"; else echo "&message=update+not+successful&"; } ?>
Thanks,Code:var Dataloader:URLLoader = new URLLoader(); var variables:URLVariables = new URLVariables(); this["btnSubmit"].addEventListener(MouseEvent.CLICK, sendData); function sendData(event:MouseEvent):void { var url:String = "C:/phpdev/www/flash/dynamicWebsite/customerUpdate.php"; var req:URLRequest = new URLRequest(url); req.method = URLRequestMethod.POST; req.data = variables; variables.cid = tiCustomerID.text; variables.fname = txtFName.text; variables.lname = txtLName.text; variables.email = txtEmail.text; variables.snum = txtSNum.text; variables.sname = txtSName.text; variables.suburb = txtSuburb.text; variables.pcode = txtPCode.text; variables.country = txtCountry.text; variables.phone = txtPhone.text; variables.user = txtUser.text; variables.upassword = txtPassword.text; //Send data to php script Dataloader.load(req); }
Nightwalker




Reply With Quote