craigtolputt Posted September 24, 2008 Share Posted September 24, 2008 Hi Guys, Sorry if this is an easy answer but i have tried to do what i think is right and it doesnt seem to work. So what i would like to do is in flash i have two text fields one is called dna_no1 and the other dna_no2. I also have a mysql database with a field called Identifier. I need the user to enter a number into dna_no1 which is already in the database then enter another number into dna_no2 which is the new number. Then i need the code which looks at the Identifier field gets the the relevant dna_no1 and changes it to the new dna_no2. this is what i tried... <?php //include the connect script include "connect.php"; /*THIS VARIABLE IS WHAT TABLE YOU ARE USING...IF YOU USED MY SQL FILE, THEN YOUR DEFAULT TABLE*/ /*NAME SHOULD BE 'userv2' AND YOU DO NOT NEED TO CHANGE ANYTHING, BUT IF YOU MADE YOUR OWN TABLE,*/ /*CHANGE THIS VARIABLE.*/ $tableName = "DNAreg"; //Post the new information they entered. $dna_no1 = $_POST['dna']; $dna_no2 = $_POST['dna2']; //if they match, update all the fields, even if they havent changed. mysql_query("UPDATE $tableName SET Identifier = '$dna_no2' WHERE Identifier = '$dna_no1'"); echo("&msgText=Successfully Updated."); } ?> also in my flash i have stop(); username.autoSize = true; //This sets a minimum character length to the dna_no field. Change how you like. var dna_noLength:Number = 8; username.text = person; dna_no1.text = "RW"; dna_no2.text = "RW"; //This variable determines if the registration completed successfully. If it did, change the submitBtn actions to go back to the login page. var success:Boolean = false; status_txt.text = ""; status_txt.autoSize = true; //Variables to hand the PHP files. var dataOut:LoadVars = new LoadVars(); var dataIn:LoadVars = new LoadVars(); //Run this once flash gets a response from the PHP. dataIn.onLoad = function() { var responsetext = this.msgText; var nametext = this.nameText; status_txt.text = responsetext; submitBtn.enabled = true; //If success change the button to continue and go back to the login screen and proceed to login. if (responsetext == "Successfully Updated.") { _global.whoReg = nametext; success = true; submitBtn.label = " Replace Another "; } }; //This is run once the user clicks on submit submitBtn.onRelease = function() { //If the user has not registered successfully yet, do this... if (success == false) { //if the dna_nos dont match, alert the user. if (dna_no1.text == dna_no2.text) { status_txt.text = "DNA Codes match!"; } else if (dna_no1.text == "RW" || dna_no2.text == "RW") { //If there are any empty fields, alert the user. status_txt.text = "Please fill in all fields."; } else { //If everything goes through, send the input data to register.php submitBtn.enabled = false; status_txt.text = "Updating...Please wait..."; dataOut.dna = dna_no1.text; dataOut.dna2 = dna_no2.text; dataOut.sendAndLoad(dnaUpdateLocation,dataIn,"POST"); } } else { //if success was equal to true, change the button actions to go back to the login screen. gotoAndPlay("replaced"); } }; //Same actions as above, just adds functionality to the enter key. var keyObj:Object = new Object(); keyObj.onKeyDown = function() { if (Key.getCode() == Key.ENTER) { if (success == false) { //if the dna_nos dont match, alert the user. if (dna_no1.text == dna_no2.text) { status_txt.text = "DNA Codes match!"; } else if (dna_no1.text == "RW" || dna_no2.text == "RW") { //If there are any empty fields, alert the user. status_txt.text = "Please fill in all fields."; } else { //If everything goes through, send the input data to register.php submitBtn.enabled = false; status_txt.text = "Updating...Please wait..."; dataOut.dna = dna_no1.text; dataOut.dna2 = dna_no2.text; dataOut.sendAndLoad(dnaUpdateLocation,dataIn,"POST"); } } else { gotoAndPlay("replaced"); } } }; Key.addListener(keyObj); If anyone can point out my mistakes i would really appreciate it. cheers Craig Quote Link to comment https://forums.phpfreaks.com/topic/125585-replacing-one-entrie-with-another/ Share on other sites More sharing options...
Adam Posted September 24, 2008 Share Posted September 24, 2008 I can't see any mistakes at all (with the PHP at least - useless with AS) but have you tried running the script itself, without the flash? Just need to create a simple HTML form linking to the script. Obviouslly if it works that would eliminate the problem being in the PHP side of it. And obviouslly if it works you'd be best seeking help in the "Other" forum... Adam Quote Link to comment https://forums.phpfreaks.com/topic/125585-replacing-one-entrie-with-another/#findComment-649309 Share on other sites More sharing options...
craigtolputt Posted September 24, 2008 Author Share Posted September 24, 2008 Ah yeah ill try that. So just a html form with two fields dna_no1 & dna_no2 and then action post and to the script??? so im a new to this Quote Link to comment https://forums.phpfreaks.com/topic/125585-replacing-one-entrie-with-another/#findComment-649310 Share on other sites More sharing options...
Adam Posted September 24, 2008 Share Posted September 24, 2008 Yeah that's right, try changing PHP to this aswell: <?php //include the connect script include "connect.php"; /*THIS VARIABLE IS WHAT TABLE YOU ARE USING...IF YOU USED MY SQL FILE, THEN YOUR DEFAULT TABLE*/ /*NAME SHOULD BE 'userv2' AND YOU DO NOT NEED TO CHANGE ANYTHING, BUT IF YOU MADE YOUR OWN TABLE,*/ /*CHANGE THIS VARIABLE.*/ $tableName = "DNAreg"; //Post the new information they entered. $dna_no1 = $_POST['dna']; $dna_no2 = $_POST['dna2']; //if they match, update all the fields, even if they havent changed. $query = mysql_query("UPDATE $tableName SET Identifier = '$dna_no2' WHERE Identifier = '$dna_no1'"); if ($query) { echo "&msgText=Successfully Updated."; } else { echo "&msgText=Update Failed."; } ?> Quote Link to comment https://forums.phpfreaks.com/topic/125585-replacing-one-entrie-with-another/#findComment-649311 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.