-
AS,PhP,MySQL Login System
hi i am getting the undefiend resoult on php feedback
php code:
<?php
include_once "connect.php";
$username = $_POST['username'];
$password = $_POST['password'];
if ($_POST['systemCall'] == "checkLogin") {
$sql = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$query = mysql_query($sql);
$login_counter = mysql_num_rows($query);
if ($login_counter > 0) {
while ($data = mysql_fetch_array($query)) {
$userbio = $data["user_bio"];
print "systemResult=$userbio";
}
} else {
print "systemResult=The login details dont match our records.";
}
}
?>
as3 code:
public function processLogin():void
{
var phpVars:URLVariables = new URLVariables();
var phpFileRequest:URLRequest = new URLRequest("http://gorgodongames.webatu.com/php/controlpanel.php");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
var phpLoader:URLLoader = new URLLoader();
navigateToURL (phpFileRequest)
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);
phpVars.systemCall = "checkLogin";
phpVars.username = username.text;
phpVars.password = password.text;
phpLoader.load(phpFileRequest);
}
public function showResult(e:Event):void
{
RTXT.autoSize = TextFieldAutoSize.LEFT;
RTXT.text = "" + e.targrt.data.systemResult;
}
the database is setup and the table is there, the connect php works fine cos i created the tables using it.
please help i am going insane here. if you cant find any error that means i set the path in my as3 code wrong but when i navigate to it it opens my php file so i dont know what to do. Help lease
Last edited by Gorgodon; 07-30-2014 at 08:04 AM.
-
.
Hi,
Try RTXT.text = "" + event.target.data.systemResult; instead of RTXT.text = "" + phpFileRequest.data.systemResult;
-
sry i udated that my phpFileRequest is a public var i just wrote it there so the path could be seen
-
.
Hi,
I get this in my flash RTXT.text
Code:
<p>You have successfully connected to a8251336_ggcoin</p><p>Tables within in a8251336_ggcoin</p>systemResult=The login details dont match our records.
<!-- Hosting24 Analytics Code -->
<script type="text/javascript" src="http://stats.hosting24.com/count.php"></script>
<!-- End Of Analytics Code -->
-
thats cos your php file is not on a server
-
.
Hi,
Perhaps this might help you along.
I didnt know your connect file
PHP Code:
<?php
$connect = mysql_connect("host","user","pass","database");
$dbase = mysql_select_db("database", $connect);
$username = $_POST['username'];
$password = $_POST['password'];
if ($_POST['systemCall'] == "checkLogin")
{
$searchString = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysql_query($searchString)
or die($searchString."<br/><br/>".mysql_error());
if (mysql_num_rows($result))
{
//echo mysql_num_rows($result);
//while ($data = mysql_fetch_array($query))
//{
//$userbio = $data["user_bio"];
$replyMessage = "1";
$sendReply = "systemResult=";
$sendReply .= rawurlencode($replyMessage);
echo $sendReply;
//}
}
else
{
$replyMessage = "2";
$sendReply = "systemResult=";
$sendReply .= rawurlencode($replyMessage);
echo $sendReply;
}
//mysql_close($connect);
}
?>
flash, altered for my use
PHP Code:
function processLogin(e:MouseEvent):void
{
var phpVars:URLVariables = new URLVariables();
phpVars.systemCall = "checkLogin";
phpVars.username = username.text;
phpVars.password = password.text;
var phpFileRequest:URLRequest = new URLRequest("connect.php");
phpFileRequest.method = URLRequestMethod.POST;
phpFileRequest.data = phpVars;
var phpLoader:URLLoader = new URLLoader();
//navigateToURL(phpFileRequest);
phpLoader.dataFormat = URLLoaderDataFormat.VARIABLES;
phpLoader.addEventListener(Event.COMPLETE, showResult);
phpLoader.load(phpFileRequest);
}
button.addEventListener(MouseEvent.CLICK,processLogin);
button.buttonMode = true;
function showResult(e:Event):void
{
if (e.target.data.systemResult == "1")
{
RTXT.autoSize = TextFieldAutoSize.LEFT;
RTXT.text = "We have a match";
}
else
{
RTXT.text = "We do no have a match";
}
}
-
thx for the reply i figured it out
Tags for this Thread
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|