Jump to content
Sign in to follow this  
Shooter

Login in flash (in an header)

Recommended Posts

Hi Everyone,I have a little problem. I have a flash login in an header and for some reason it does not work at all. It keeps saying that "you have the wrong username/password" even if your login information are okay.Here is the flash code..

on (release){	var _loc4 = "login_flash.php";	var _loc3 = new LoadVars();	var _loc2 = new LoadVars();	_loc3.onclick = function (success)	{		if (success)		{			if (this.error == "none")			{				trace ("Everything\'s okay!");				getURL("index.php");			}			else			{				trace ("Something went wrong");				trace (_loc2);				getURL("index.php?act=login&error=true");			} // end else if		}		else		{			trace ("Error connecting to server.");			getURL("index.php?act=login&error=true");		} // end else if	};	_loc2.loginusername = _root.login.uname.text;	_loc2.loginpassword = _root.login.passw.text;	_loc2.sendAndLoad(_loc4, _loc3, "POST");}on (rollOver){	gotoAndPlay(2);}on (rollOut){	gotoAndPlay(11);}

If you have any ideas why, please let me know.(I'm not the person who did this code, I'm not able to reach him so I figured I would ask here.)Thanks.

Share this post


Link to post
Share on other sites

To help you better, do you have a link to the site its at, or the forums it's tying in to? I'm not sure if firebug catches flash, but you can use that to see what your posting to the next page, to see if it matches up with the equivlant html login.

Share this post


Link to post
Share on other sites

It redirects on two occasions to say there's an error, do you know which of those it is doing? If you're testing this live where trace statements aren't going to work then add another parameter to the URL so you can see if it's redirecting because it couldn't contact the server or because the error variable was set.

Share this post


Link to post
Share on other sites

I am not an expert in FLASH, like I said I'm not the person who did this code. I tried to add some stuff like you said, but... the "GO" button does not work anymore.Here is the link to the website. np.validns.com

Share this post


Link to post
Share on other sites

Just add something to the end of the URL that it's redirecting to. e.g.:getURL("index.php?act=login&error=true&badpass");getURL("index.php?act=login&error=true&noconnect");for the first and second redirects. When the page redirects you can look at the URL to figure out which redirect it used.

Share this post


Link to post
Share on other sites

It brings me to this : http://np.validns.com/index.php?act=login&...rue&badpass

 on (release){	var _loc4 = "login_flash.php";	var _loc3 = new LoadVars();	var _loc2 = new LoadVars();	_loc3.onLoad = function (success)	{		if (success)		{			if (this.error == "none")			{				trace ("Everything\'s okay!");				getURL("index.php");			}			else			{				trace ("Something went wrong");				trace (_loc2);				getURL("index.php?act=login&error=true&badpass");			} // end else if		}		else		{			trace ("Error connecting to server.");			getURL("index.php?act=login&error=true&noconnect");		} // end else if	};	_loc2.loginusername = _root.login.uname.text;	_loc2.loginpassword = _root.login.passw.text;	_loc2.sendAndLoad(_loc4, _loc3, "POST");}on (rollOver){	gotoAndPlay(2);}on (rollOut){	gotoAndPlay(11);}

Share this post


Link to post
Share on other sites

It will redirect there if this.error does not equal "none", so you'll probably want to print this.error to see what it is. If you need to, you can add a dynamic text field and use that as debug output. You write to a dynamic text field using its text property.dyn_text.text = this.error;

Share this post


Link to post
Share on other sites

There is a toolbar on the left that contains a text box tool, so you draw a textbox out and set whatever text options you want on the bottom in the properties panel. Change the type to Dynamic, and give the text box a unique name in the instance name box. You refer to the textbox in the code with the instance name. e.g. if you call the box "dyn_text" then you use this:dyn_text.text = this.error;You might have to play around to get the scope right, so instead of writing just the error message also write some plain text to make sure that you can write to the text field in the first place.dyn_text.text = "Error text:\n";dyn_text.text += this.error;

Share this post


Link to post
Share on other sites

As you can see on "np.validns.com" I added the box and everything.Here is the code.

 on (release){	var _loc4 = "login_flash.php";	var _loc3 = new LoadVars();	var _loc2 = new LoadVars();	_loc3.onLoad = function (success)	{		if (success)		{			if (this.error == "none")			{				trace ("Everything\'s okay!");				getURL("index.php");			}			else			{				trace ("Something went wrong");				trace (_loc2);				getURL("index.php?act=login&error=true");				dyn_text.text += this.error;			} // end else if		}		else		{			trace ("Error connecting to server.");			getURL("index.php?act=login&error=true");		} // end else if	};	_loc2.loginusername = _root.login.uname.text;	_loc2.loginpassword = _root.login.passw.text;	_loc2.sendAndLoad(_loc4, _loc3, "POST");}on (rollOver){	gotoAndPlay(2);}on (rollOut){	gotoAndPlay(11);}

The text does not change! Did I do something wrong?

Share this post


Link to post
Share on other sites

It's probably not finding the text box. If you're editing Actionscript, in the Actionscript window there's a button with a crosshair on it. If you click that you can browse to find your text box, and check the Absolute radio button to put in the absolute path to the text box. The code probably isn't finding an object called dyn_text in the scope that it's looking. The absolute name will be something like _root.dyn_text. Also make sure that the text box has "dyn_text" as the instance name.

Share this post


Link to post
Share on other sites

That message is coming from the PHP file, you would need to look at the code in there to figure out what condition causes that message to be sent.

Share this post


Link to post
Share on other sites

In PHP, you can use print_r($_POST). If the PHP page doesn't actually show up in a browser, you would need to use file_put_contents to write it to a file and then look at the file.file_put_contents('debug.txt', print_r($_POST, true));You can also use a debugger like Firebug to look at the actual request going out and the response that comes back.

Share this post


Link to post
Share on other sites

Well I guess, I guess it could be anything. That's why you use something like PHP or Firebug to print all of the data out so you can look at it and figure out if it's a problem or not. With PHP you can print $_POST, $_GET, $_SESSION, $_COOKIE, $_SERVER etc to see what information PHP is using. If you use Firebug you can also see all of the HTTP headers, the $_SERVER array only contains certain headers. I'm not telling you that the PHP code is wrong, but you asked how to look at the information that got submitted and printing that information out in PHP is the way I normally use. You can use whatever method you want.

Share this post


Link to post
Share on other sites

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.   Paste as plain text instead

  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.

Loading...
Sign in to follow this  

×
×
  • Create New...