Log In script :: CS5/AS2/PHP Please help
I would really appreciate some help with my script.
My flash login form is not passing the variables to my
php script.
I have a log in form:
- email field: instance name = e_mail / variable = email
- password field: instance name = pw / variable = pass
- error meggase field : variable = error_msg
My AS looks like this:
Code:
stop();
/------------------------------------------
logbtn.onRelease = function() {
if (e_mail.length<1) {
error_msg = "Introducir Correo";
}
else if (pw.length<1) {
error_msg = "Introducir ContraseƱa";
}
loadVariablesNum("login2.php", 0, "POST");
}
My php code looks like this:
PHP Code:
<?php
require("include/dbconnect2.php");
$e_mail = $_POST['email'];
$pw = $_POST['pass']; //retreive the variables from flash.
$result = mysql_query("SELECT email, pass FROM registration ");
$row = mysql_fetch_array($result);
$f_email=$row['email'];
$f_pass=$row['pass'];
if($e_mail == $f_email && $pw == $f_pass)
{
echo "&error_msg=Loging Successful.";
}
else {
echo "&error_msg=Login Failed";
}
?>
The php script works itself, if i set the variables like
PHP Code:
$e_mail = '[email protected]'; //dummy user email i put in my db
$pw = '123456';
$result = mysql_query("SELECT email, pass FROM registration ");
$row = mysql_fetch_array($result);
$f_email=$row['email'];
$f_pass=$row['pass'];
if($e_mail == $f_email && $pw == $f_pass)
{
echo "Loging Successful.";
}
It works, but when passing the variables from flash is not working. Instead, on my error_msg i get the echo from php "Login Failed" even i enter the correct user email and password that i entered in my DB.
Yes, I know I'm able to conect to my db successfully so it's not a db connection problem.
I created a registration form and i pass the variables to my register.php with no problems and user gets put into my db. so im not sure why it doesnt pass variables to php when trying to log in.
Any ideas what I'm doing wrong in flash?
PS: i know i should use
PHP Code:
('SELECT * FROM registration WHERE email =$email, AND pass=$pw);
but i get a mysql error.
I appreciate any help in advanced. Thanks