Twister1004 Posted February 20, 2009 Share Posted February 20, 2009 Hello everyone. I'm new to flash. I'm not coding the flash, however someone else I know is. He has no knowledge of PHP, but I do. I have no knowledge in Flash except that it seems like javascript, but he does. So, I am wondering if someone maybe willing to help me out with this. In the actionscript he did //On first frame stop(); userinput.restrict="a-zA-Z0-9"; Selection.setFocus(userinput); passinput.restrict="a-zA-Z0-9"; status="Enter your information and submit"; this.onEnterFrame = function () { if(_root.checklog == 1){ _root.gotoAndStop(2); } if(_root.checklog == 2){ _root.gotoAndStop(3); } } ////////////////////////////// On submit button. on (release, keyPress "<Enter>") { if (user != "" && pass != "") { status = "Begin Login Process - Wait..."; loadVariablesNum("testscript.php", 0, "POST"); } } Now, I have no idea what to do. Here is what I wrote in testscript.php <?php if(isset($_POST['submit'])){ $username = $_POST['user']; $password = $_POST['pass']; if($user != "Tyler") $error = "Username does not exist."; elseif($pass != "shadows2"){ $error = "Password is incorrect"; } else{ if($error){ echo $error; } else{ echo $error; } } } ?> I was mostly looking around and found some similarities. However, I don't know if they are correct or not. Thank you for your help - Twister Quote Link to comment https://forums.phpfreaks.com/topic/146043-actionscript-help/ Share on other sites More sharing options...
corbin Posted February 20, 2009 Share Posted February 20, 2009 Hrmmm.... If I remember correctly, you have to use the object form of loadVariables to send POST data. Quote Link to comment https://forums.phpfreaks.com/topic/146043-actionscript-help/#findComment-766717 Share on other sites More sharing options...
Twister1004 Posted February 22, 2009 Author Share Posted February 22, 2009 Ok, well, I'm having another issue. It doesn't want to connect to my database to check. I am getting nothing wrong when I check just the PHP file. So I'm kinda confused. Would anyone be so kind as to help me? The action script is, tError.autoSize = "right"; var lvSend:LoadVars = new LoadVars(); var lvReceive:LoadVars = new LoadVars(); mcLogin.onRelease = function() { lvSend.username = tUsername.text; lvSend.password = tPassword.text; lvSend.sendAndLoad("logincheck.php", lvReceive, "POST"); }; lvReceive.onLoad = function(success:Boolean) { if (success) { if (this.login == "success") { getURL("members.php"); }else{ tError.text = "I'm sorry you did not enter valid login details"; } } else { trace("no reponse from server"); } }; Here is the PHP file <?php error_reporting(E_ALL); session_start(); mysql_connect("localhost", "root", "shadows2"); mysql_select_db("abysmal"); $username = $_POST['username']; $password = $_POST['password']; /*-----------------LOGIN------------------*/ $sql = mysql_query("SELECT * FROM `accounts` WHERE `MID` = '$username' AND `password` = '$password' LIMIT 1") or die(mysql_error()); echo "SQL passes"; if(mysql_num_rows($sql) < 0){ echo '&text="You did not enter the correct details, or the server is not working."'; echo "Passes1"; } else{ while($data = mysql_fetch_array($sql)){ if(!isset($_SESSION['id'])){ echo "passes"; $_SESSION['loggedIn'] = true; $_SESSION['id'] = $data['id']; $_SESSION['name'] = $data['first']; $_SESSION['mid'] = $data['MID']; echo 'login=success'; } } echo "passes2"; } /* //in real life you will probably want to check whether the username/password exist in a database instead if($username == 'admin' && $password == 'admin123'){ $_SESSION['loggedIn'] = true; echo 'login=success'; }else{ echo 'login=failure'; }*/ ?> <?php error_reporting(E_ALL); session_start(); mysql_connect("localhost", "root", "shadows2"); mysql_select_db("abysmal"); $username = $_POST['username']; $password = $_POST['password']; /*-----------------LOGIN------------------*/ $sql = mysql_query("SELECT * FROM `accounts` WHERE `MID` = '$username' AND `password` = '$password' LIMIT 1") or die(mysql_error()); echo "SQL passes"; if(mysql_num_rows($sql) < 0){ echo '&text="You did not enter the correct details, or the server is not working."'; echo "Passes1"; } else{ while($data = mysql_fetch_array($sql)){ if(!isset($_SESSION['id'])){ echo "passes"; $_SESSION['loggedIn'] = true; $_SESSION['id'] = $data['id']; $_SESSION['name'] = $data['first']; $_SESSION['mid'] = $data['MID']; echo 'login=success'; } } echo "passes2"; } /* //in real life you will probably want to check whether the username/password exist in a database instead if($username == 'admin' && $password == 'admin123'){ $_SESSION['loggedIn'] = true; echo 'login=success'; }else{ echo 'login=failure'; }*/ ?> [/code] Quote Link to comment https://forums.phpfreaks.com/topic/146043-actionscript-help/#findComment-768133 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.