0 Replies - 2850 Views - Last Post: 28 November 2012 - 05:49 AM

#1 akhtarnawaz786  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 2
  • Joined: 28-November 12

Login by flash,php and mysql

Posted 28 November 2012 - 05:49 AM

i'm just creating simple login for using flash and php with mysql.flash interface on client side and php script on server side to check the login authentication from mysql database.my php script is working fine, i mean its verifying email and password from the database but my flash script is not communication with php script i think, i'm giving the code can any one help me plaese.
<?php
session_start();
$db=mysql_connect("mysql5.000webhost.com", "***", "***");
mysql_select_db("a8915214_DB", $db);
$email = $_POST['email'];
$password = $_POST['password'];

$SQL = "SELECT * FROM login WHERE  email ='".$email."' AND password = '".$password."'";

$rs = mysql_query($SQL);
$numRows = mysql_num_rows($rs);
if($numRows > 0){
	$_SESSION['loggedIn'] = true;
	echo 'login=success';
}else{
	echo 'login=failure';
}
?>



my flash code is as follows:


var lvSend:LoadVars = new LoadVars();
var lvReceive:LoadVars = new LoadVars();
tError.autoSize = "right";
mcLogin.onRelease = function() {
	trace("Value92076 :"+_root.usertext1.text);
	var valid:Boolean = validateForm();
	if (valid) {
	lvSend.email = tEmail.text;
	lvSend.password = tPassword.text;
	lvSend.sendAndLoad("newlogin.php",lvReceive,"POST");
	} else {
		tError.text("Please complete all fields");
	}
};

function validateForm():Boolean {
	if (tEmail.text == "" || tPassword.text == "" ) {
		tError.text="Please fill all the fields!";
		return false;
	} 
	else if (tEmail.text == "") {
		tError.text="Please enter valid email address!";
		return false;
	} else if (tEmail.text.indexOf("@") == -1 || tEmail.text.indexOf(".") == -1) {
		tError.text="Please enter valid email address!";
		return false;
	}
	return true;
}


lvReceive.onload = function(success:Boolean) {
	if (success) {
		if (this.login== "success") {
			loadMovieNum("logout.swf", 5);
			usertext1.text=tEmail.text;
			//gotoAndStop(821);
            
		} else {
			tError.text = "I'm sorry you did not enter valid login details";
		}
	} else {
		tError.text = "No reponse from server.Check your firewall and internet connection.";
	}
};



i am new on flash thats why see king a man could help me.i know its quite easy for a man aware of flash, please guys help me get out of this problem. thanks in advance.

MOD EDIT: Added code tags. Also removed DB credentials, geez, don't post passwords on the Internet!!! And when posting code...USE CODE TAGS!!!

:code:/>

This post has been edited by JackOfAllTrades: 28 November 2012 - 06:47 AM


Is This A Good Question/Topic? 0
  • +

Page 1 of 1