Hi,
Firstly you were not sending any vars to the php form, nor retrieving any, so you wold not have gotten any response.
So with a bit of alteration, as you did not attach your fla.
instead of placing the code on the button, put the code on the timeline where you can access it easier.
Also I suggest not using vars but use the textfield name instead.
Fla:
PHP Code:
var phpPath:String = "login.php";
var varsToSend:LoadVars;
var varsToFetch:LoadVars;
passText.password = true;
logButton.onRelease = function()
{
if (userText.text != "" && passText.text != "")
{
varsToSend = new LoadVars();
varsToSend.username = userText.text;
varsToSend.passname = passText.text;
varsToFetch = new LoadVars();
varsToSend.sendAndLoad(phpPath,varsToFetch,"POST");
varsToFetch.onLoad = dataReturned;
trace(varsToSend);
}
else
{
trace("Please fill in both username and password");
replyText.text = "Username and password required";
}
};
function dataReturned(passed:Boolean)
{
if (passed)
{
replyText.text = this.words;
}
else
{
replyText.text = "Error connecting to server.";
}
}
this one does both username and password together, it would take a few more lines of code and my time to make it log in in stages.
This is not encrypted so anybody can view the password across the net, you might want to look into using sha1 or md5 or any form of encryption for future use.
php:
PHP Code:
<?php
error_reporting(E_ALL ^ E_DEPRECATED);
$connect = mysql_connect("localhost","dataBaseOwner***","ownerPass***", "dataBaseName");
$dbase = mysql_select_db("dataBaseName", $connect);
$username = mysql_real_escape_string($_POST['username'],$connect);
$password = mysql_real_escape_string($_POST['passname'],$connect);
$check = "SELECT * FROM users WHERE username='$username' AND password='$password'";
$result = mysql_query($check) or die();
if (mysql_num_rows($result))
{
while ($data = mysql_fetch_array($result))
{
echo "words=This username and password are recognised, you are logged in.";
}
}
else
{
echo "words=This username and password is not recognised.";
mysql_close($connect);
}
?>
I dont know what phph version you use at home but after 5.5 you will start to need to use mysqli
so this is added error_reporting(E_ALL ^ E_DEPRECATED);
http://stackoverflow.com/questions/2...-mysql-connect