Jump to content

Recommended Posts

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

Link to comment
https://forums.phpfreaks.com/topic/146043-actionscript-help/
Share on other sites

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]

Link to comment
https://forums.phpfreaks.com/topic/146043-actionscript-help/#findComment-768133
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.